/* ================================================================
   K.J.dex v6 — 千问办公风 v6
   整体化输入框 + WorkBuddy 风左栏 + 赛博朋克登录页
   ================================================================ */

:root, [data-theme="light"] {
  --bg: #f5f6f8;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f5f6f8;
  --bg-hover: #f0f1f5;
  --bg-active: #e8eaf3;
  --text: #1a1d28;
  --text-secondary: #5a5f72;
  --text-muted: #8a8e9a;
  --accent: #3b6fe0;
  --accent-hover: #2a5dd0;
  --accent-soft: #e8efff;
  --border: #e8eaef;
  --border-light: #d8dae0;
  --user-bubble: linear-gradient(135deg,#3b6fe0,#6a4be0);
  --ai-bubble: #f5f6f8;
  --shadow: 0 1px 3px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.08);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --sidebar-w: 280px;
  --topbar-h: 52px;
  --font: "Nunito","Noto Sans SC",-apple-system,"PingFang SC","Microsoft YaHei",sans-serif;
  --mono: "JetBrains Mono","Fira Code",monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0a0b10;
  --bg-sidebar: #13141c;
  --bg-card: #1a1b24;
  --bg-input: #13141c;
  --bg-hover: #1e2030;
  --bg-active: #252848;
  --text: #e8eaef;
  --text-secondary: #b8bccc;
  --text-muted: #6e7282;
  --accent: #5b8cff;
  --accent-hover: #7c9fff;
  --accent-soft: rgba(91,140,255,.12);
  --border: #2a2d3a;
  --border-light: #1e2030;
  --user-bubble: linear-gradient(135deg,#5b8cff,#7c5cff);
  --ai-bubble: #1a1b24;
  --shadow: 0 1px 3px rgba(0,0,0,.2), 0 6px 20px rgba(0,0,0,.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font); font-weight: 600;
  background: var(--bg); color: var(--text);
  display: flex; transition: background .3s, color .3s;
}
a { text-decoration: none; color: inherit; cursor: pointer; }
button { border: none; background: none; cursor: pointer; font-family: inherit; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }

.bi { display: inline-flex; flex-direction: column; line-height: 1.25; }
.bi > .zh { font-weight: 700; }
.bi > .en { font-size: .8em; opacity: .72; font-family: "Nunito"; font-weight: 500; letter-spacing: .2px; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
.hidden { display: none !important; }

/* ================================================================
   按钮 3D 立体化（凹凸 + 点击光影）
   ================================================================ */
.sb-new-btn, .sb-login-btn, .tool-btn, .tool-send, .kb-add-btn,
.mbtn, .lbtn, .sug-item, .sb-nav-item, .login-close, .mclose {
  position: relative;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.25),
    inset 0 -2px 0 rgba(0,0,0,.12),
    0 2px 4px rgba(0,0,0,.1);
  transition: all .12s ease;
  transform: translateY(0);
}
.sb-new-btn:hover, .sb-login-btn:hover, .tool-btn:hover, .tool-send:hover,
.kb-add-btn:hover, .mbtn:hover, .lbtn:hover, .sug-item:hover, .sb-nav-item:hover {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.35),
    inset 0 -2px 0 rgba(0,0,0,.08),
    0 4px 10px rgba(0,0,0,.14);
  transform: translateY(-1px);
}
.sb-new-btn:active, .sb-login-btn:active, .tool-btn:active, .tool-send:active,
.kb-add-btn:active, .mbtn:active, .lbtn:active, .sug-item:active, .sb-nav-item:active,
.login-close:active, .mclose:active {
  box-shadow:
    inset 0 2px 6px rgba(0,0,0,.22),
    inset 0 -1px 0 rgba(255,255,255,.08);
  transform: translateY(1px);
}

/* ==================== LEFT SIDEBAR (WorkBuddy 复刻) ==================== */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}
.sb-brand { padding: 20px 24px 14px; display: flex; justify-content: center; }
.sb-logo { width: 100%; height: auto; max-height: 130px; object-fit: contain; }

.sb-new-btn {
  margin: 0 14px 12px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 700;
  transition: opacity .15s;
}
.sb-new-btn:hover { opacity: .9; }

.sb-nav { padding: 4px 8px; display: flex; flex-direction: column; gap: 1px; }
.sb-nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 12px; border-radius: var(--radius-xs);
  color: var(--text-secondary); font-size: 13px;
  transition: all .15s; text-align: left;
  position: relative;
}
.sb-nav-item:hover { background: var(--bg-hover); color: var(--text); }
.sb-nav-tag {
  margin-left: auto; font-size: 10px; padding: 1px 6px;
  background: var(--bg-hover); color: var(--text-muted);
  border-radius: 8px; font-weight: 700;
}

.sb-section { flex: 1; overflow: hidden; display: flex; flex-direction: column; padding: 12px 8px 4px; min-height: 80px; }
.sb-section-title {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px 6px; font-size: 11px;
  color: var(--text-muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
}
.sb-section-count {
  margin-left: auto; font-size: 10px; padding: 1px 6px;
  background: var(--bg-hover); color: var(--text-secondary);
  border-radius: 8px; font-weight: 700;
}
.sb-sessions { flex: 1; overflow-y: auto; }
.sb-sess-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: var(--radius-xs);
  color: var(--text-secondary); font-size: 13px;
  cursor: pointer; transition: all .15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-sess-item:hover { background: var(--bg-hover); color: var(--text); }
.sb-sess-empty { padding: 12px; color: var(--text-muted); font-size: 12px; text-align: center; }

.sb-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
}
.sb-user { flex: 1; display: flex; align-items: center; gap: 8px; color: var(--text-secondary); min-width: 0; }
.sb-user-avatar { font-size: 18px; }
.sb-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.sb-icon-btn {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: background .15s;
}
.sb-icon-btn:hover { background: var(--bg-hover); }
.sb-login-btn {
  padding: 4px 10px; border-radius: var(--radius-xs);
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
}
.sb-login-btn:hover { opacity: .88; }

/* ==================== MAIN AREA ==================== */
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
}
.topbar-menu { display: none; font-size: 18px; padding: 6px 10px; border-radius: var(--radius-xs); }
.topbar-menu:hover { background: var(--bg-hover); }
.topbar-title { font-size: 14px; font-weight: 700; color: var(--text); }
.topbar-right { margin-left: auto; }

/* ===== Model Selector ===== */
.model-selector { position: relative; }
.model-dropdown {
  position: absolute; bottom: calc(100% + 6px); right: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px;
  min-width: 320px; max-height: 60vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); z-index: 100;
  display: none;
}
.model-dropdown.open { display: block; }
.model-card {
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s;
  border: 1px solid transparent;
}
.model-card:hover { background: var(--bg-hover); }
.model-card.active { background: var(--accent-soft); border-color: var(--accent); }
.mc-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.mc-name { font-size: 14px; font-weight: 800; color: var(--text); }
.mc-free-badge {
  display: inline-block; padding: 1px 6px; border-radius: 8px;
  font-size: 10px; font-weight: 700; line-height: 1.4;
}
.mc-free-badge.free { background: #d4f4dd; color: #1a8b3e; }
.mc-free-badge.paid { background: #ffe8d0; color: #c45a00; }
.mc-detail { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* ==================== PAGES ==================== */
.page { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ==================== WELCOME PAGE ==================== */
.welcome-zone {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  padding: 40px 20px 20px; overflow: auto;
  background: var(--bg);
}
.welcome-msg-block {
  display: flex; align-items: flex-start; justify-content: center;
  width: 100%; max-width: 820px; margin-bottom: 24px;
}
.welcome-msg-text { flex: 1; }
.welcome-greeting {
  font-size: 28px; font-weight: 800; line-height: 1.3;
  margin-bottom: 4px; color: var(--text);
}
.welcome-sub {
  font-size: 22px; font-weight: 700; line-height: 1.3;
  color: var(--text-secondary);
}

/* ===== 整体化 INPUT STACK（一个蓝色描边的大框） ===== */
.input-stack {
  width: 100%; max-width: 820px;
  display: flex; flex-direction: column;
  position: relative;
}
.input-card-big {
  padding: 14px 16px 10px;
  border-radius: var(--radius);
  background: var(--bg-card);
  /* 蓝色渐变描边 */
  border: 2px solid transparent;
  background-image:
    linear-gradient(var(--bg-card), var(--bg-card)),
    linear-gradient(135deg, #3b6fe0 0%, #5b8cff 30%, #7c5cff 60%, #5b8cff 100%);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: var(--shadow-md);
  transition: all .2s;
}
.input-card-big:focus-within {
  background-image:
    linear-gradient(var(--bg-card), var(--bg-card)),
    linear-gradient(135deg, #5b8cff 0%, #7c5cff 50%, #5b8cff 100%);
  box-shadow: 0 0 0 4px rgba(91,140,255,.18), var(--shadow-md);
}
.ic-textarea-big {
  width: 100%; resize: none; border: none; outline: none;
  background: transparent; color: var(--text);
  font-size: 15px; line-height: 1.6;
  padding: 4px 4px 8px; min-height: 28px; max-height: 260px;
  display: block;
}
.ic-textarea-big::placeholder { color: var(--text-muted); }

/* 小龙人趴着姿态：头部探出输入框上方，紧贴文本框边缘 */
.welcome-mascot {
  position: absolute; top: -116px; right: 24px;
  width: 120px; height: auto;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,.15));
  z-index: 10;
  pointer-events: auto;
}
.welcome-mascot:hover { transform: scale(1.05); }

.chat-mascot {
  position: absolute; top: -116px; right: 24px;
  width: 120px; height: auto;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,.15));
  z-index: 10;
}
.chat-mascot:hover { transform: scale(1.05); }

.input-tools {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.tools-left, .tools-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary);
  font-size: 12px; font-weight: 700;
  transition: all .15s;
}
.tool-btn:hover { background: var(--bg-hover); color: var(--text); }
.model-inline { padding: 6px 10px; }
.model-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: linear-gradient(135deg,#3b6fe0,#6a4be0);
}
.model-caret { font-size: 9px; opacity: .6; }
.tool-send {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; margin-left: 4px;
  transition: opacity .15s, transform .15s;
  box-shadow: 0 2px 8px rgba(59,111,224,.3);
}
.tool-send:hover { opacity: .9; transform: scale(1.05); }
.tool-send:disabled { opacity: .4; cursor: not-allowed; }

.ic-perm-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); display: inline-block;
}

/* ===== SUGGESTIONS ===== */
.suggestions-list {
  width: 100%; max-width: 820px;
  margin-top: 16px; display: flex; flex-direction: column; gap: 6px;
}
.sug-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-secondary);
  cursor: pointer; transition: all .15s;
  text-align: left; width: 100%;
}
.sug-item:hover { background: var(--bg-hover); color: var(--text); }
.sug-icon { font-size: 14px; opacity: .7; flex-shrink: 0; }
.sug-text { flex: 1; }

.ai-footnote {
  margin-top: 14px; font-size: 11px; color: var(--text-muted);
  text-align: center; opacity: .7;
}

/* ==================== CHAT PAGE ==================== */
.chat-messages { flex: 1; overflow-y: auto; padding: 24px 16px 8px; }
.msg { display: flex; margin-bottom: 14px; max-width: 90%; }
.msg-user { margin-left: auto; flex-direction: row-reverse; }
.msg-ai { margin-right: auto; }
.msg-bubble {
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 14px; line-height: 1.6; word-break: break-word;
}
.msg-user .msg-bubble {
  background: var(--user-bubble); color: #fff;
  border-top-right-radius: 4px;
}
.msg-ai .msg-bubble {
  background: var(--ai-bubble); color: var(--text);
  border-top-left-radius: 4px;
}
.msg-rag-tag {
  display: inline-block; margin-top: 4px; padding: 1px 6px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 6px; font-size: 10px; font-weight: 700;
}
.msg-streaming::after {
  content: '▍'; color: var(--accent); animation: blink 1s infinite;
  font-weight: 800;
}
@keyframes blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }

.chat-input-zone {
  flex-shrink: 0; padding: 16px 20px 8px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  position: relative;
}
.chat-stack { max-width: 820px; margin: 0 auto; }

/* ==================== KNOWLEDGE PAGE ==================== */
.kb-container { flex: 1; padding: 24px 32px; overflow-y: auto; }
.kb-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.kb-header h2 { font-size: 20px; font-weight: 800; }
.kb-add-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 700;
}
.kb-add-btn:hover { opacity: .9; }
.kb-list { display: flex; flex-direction: column; gap: 8px; }
.kb-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: all .15s;
}
.kb-item:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.kb-item-icon { font-size: 20px; }
.kb-item-body { flex: 1; min-width: 0; }
.kb-item-title { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.kb-item-meta { font-size: 12px; color: var(--text-muted); }
.kb-item-del { padding: 4px 10px; border-radius: var(--radius-xs); color: #c44; font-size: 12px; }
.kb-item-del:hover { background: #fce8e8; }
.kb-stats { margin-top: 16px; font-size: 12px; color: var(--text-muted); text-align: center; }

/* ==================== LOGIN PAGE (赛博朋克全屏背景) ==================== */
.login-page {
  position: fixed; inset: 0; z-index: 800;
  background: url('login-bg.webp') center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
}
.login-page::before {
  content: ''; position: absolute; inset: 0;
  background: rgba(0,0,0,.4); backdrop-filter: blur(2px);
}
.login-card {
  position: relative; z-index: 1;
  width: 420px; max-width: 92vw;
  background: rgba(19,20,28,.82);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px; padding: 36px 32px 28px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,.5), 0 0 80px rgba(91,140,255,.1);
  backdrop-filter: blur(20px);
  color: #fff;
}
.login-close {
  position: absolute; top: 14px; right: 16px;
  font-size: 22px; color: rgba(255,255,255,.5);
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.login-close:hover { background: rgba(255,255,255,.1); color: #fff; }
.login-logo {
  height: 150px; margin: 0 auto 20px; display: block;
  filter: brightness(1.4) contrast(1.08) drop-shadow(0 0 24px rgba(255,255,255,.35));
}
.login-sub { font-size: 12px; color: rgba(255,255,255,.6); margin-bottom: 22px; }
.login-tabs { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,.1); }
.ltab {
  flex: 1; padding: 10px; font-size: 14px; font-weight: 700;
  color: rgba(255,255,255,.5); border-bottom: 2px solid transparent;
  transition: all .15s;
}
.ltab.active { color: #fff; border-bottom-color: #5b8cff; }
.linput {
  width: 100%; padding: 12px 14px; margin-bottom: 12px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-sm); color: #fff;
  outline: none; font-size: 14px; transition: all .15s;
}
.linput::placeholder { color: rgba(255,255,255,.4); }
.linput:focus { border-color: #5b8cff; box-shadow: 0 0 0 3px rgba(91,140,255,.2); }
.lbtn {
  width: 100%; padding: 12px; margin-top: 6px;
  background: linear-gradient(135deg, #3b6fe0, #6a4be0);
  color: #fff; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 800;
  transition: opacity .15s;
  box-shadow: 0 4px 16px rgba(59,111,224,.3);
}
.lbtn:hover { opacity: .92; }
.lerror { color: #ff8a8a; font-size: 13px; margin-top: 10px; min-height: 20px; }
.login-foot {
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px; color: rgba(255,255,255,.4);
  line-height: 1.8;
}
.login-tel { font-size: 12px; color: rgba(255,255,255,.6); letter-spacing: .5px; }

/* ===== 页脚电话 ===== */
.footer-tel { color: var(--text-secondary); }

/* ==================== KB MODAL (保留旧 modal 弹窗) ==================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 28px 24px;
  width: 380px; max-width: 90vw; position: relative;
  box-shadow: var(--shadow-lg); text-align: center;
}
.modal-title {
  font-size: 20px; font-weight: 800; margin-bottom: 18px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.minput {
  width: 100%; padding: 12px 14px; margin-bottom: 10px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  outline: none; font-size: 14px; transition: border-color .15s;
}
.minput:focus { border-color: var(--accent); }
.kb-textarea { resize: vertical; min-height: 100px; font-family: inherit; }
.mbtn {
  width: 100%; padding: 12px; margin-top: 4px;
  background: var(--accent); color: #fff; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700; transition: opacity .15s;
}
.mbtn:hover { opacity: .85; }
.merror { color: #e55; font-size: 13px; margin-top: 10px; min-height: 20px; }
.mclose {
  position: absolute; top: 12px; right: 14px; font-size: 18px;
  color: var(--text-muted); padding: 4px; border-radius: 50%;
  transition: background .15s;
}
.mclose:hover { background: var(--bg-hover); }

/* ===== 权限选择器 ===== */
.perm-selector { position: relative; }
.perm-dropdown {
  position: absolute; bottom: calc(100% + 6px); left: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px; min-width: 230px;
  box-shadow: var(--shadow-lg); z-index: 100; display: none;
}
.perm-dropdown.open { display: block; }
.perm-item {
  padding: 8px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s;
}
.perm-item:hover { background: var(--bg-hover); }
.perm-item.active { background: var(--accent-soft); }
.perm-name { font-size: 13px; font-weight: 800; color: var(--text); }
.perm-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ===== Agent 工具卡片 ===== */
.tool-card {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 12px; margin: 6px 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12px;
}
.tool-card .tc-icon { font-size: 16px; margin-top: 2px; }
.tool-card .tc-body { flex: 1; min-width: 0; }
.tool-card .tc-name { font-weight: 800; font-size: 13px; color: var(--accent); }
.tool-card .tc-status { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.tool-card .tc-args {
  font-family: var(--mono); font-size: 11px; color: var(--text-secondary);
  margin-top: 4px; white-space: pre-wrap; word-break: break-all;
}
.tool-card.running { border-color: var(--accent); }
.tool-card.done { border-color: var(--border); opacity: .85; }
.tool-card.failed { border-color: #e55; }
.tc-spin { display: inline-block; animation: tcSpin 1s linear infinite; }
@keyframes tcSpin { 100% { transform: rotate(360deg); } }

/* ===== Agent 思考提示 ===== */
.thinking-hint {
  font-size: 12px; color: var(--text-muted); margin: 4px 0 8px;
  display: flex; align-items: center; gap: 6px;
}

/* ===== 审批弹窗 ===== */
.approve-tool-name {
  font-size: 15px; font-weight: 800; color: var(--accent);
  margin-bottom: 10px; text-align: center;
}
.approve-args {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px;
  font-family: var(--mono); font-size: 12px;
  color: var(--text-secondary); max-height: 180px; overflow: auto;
  text-align: left; white-space: pre-wrap; word-break: break-all;
  margin-bottom: 16px;
}
.approve-btns { display: flex; gap: 10px; }
.approve-btns .mbtn { flex: 1; }
.approve-no { background: #d9534f !important; }

/* ===== 计划弹窗 ===== */
.plan-text {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
  font-size: 13px; line-height: 1.7; text-align: left;
  max-height: 40vh; overflow: auto; margin-bottom: 16px;
  color: var(--text);
}
.plan-text pre { white-space: pre-wrap; font-family: inherit; }

/* ===== 工作区面板 ===== */
.workspace-panel {
  position: fixed; right: 16px; top: 60px; width: 300px; max-height: 60vh;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 400; overflow: hidden; display: none;
}
.workspace-panel.open { display: block; }
.wp-header {
  padding: 10px 14px; font-size: 13px; font-weight: 800;
  border-bottom: 1px solid var(--border); display: flex; justify-content: space-between;
}
.wp-list { padding: 8px; overflow: auto; max-height: calc(60vh - 40px); }
.wp-file {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: var(--radius-xs);
  font-size: 12px; color: var(--text-secondary);
  font-family: var(--mono); cursor: default;
}
.wp-file:hover { background: var(--bg-hover); }
.wp-file .wp-size { margin-left: auto; font-size: 10px; color: var(--text-muted); }

/* ===== 应用中心（旧构件集成 · 可折叠） ===== */
.sb-apps-section { flex-shrink: 0; }
.apps-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  border-radius: var(--radius-xs);
  transition: background .15s;
}
.apps-toggle:hover { background: var(--bg-hover); }
.apps-caret {
  font-size: 10px; color: var(--text-muted);
  transition: transform .2s; display: inline-block;
}
.sb-apps-section:not(.collapsed) .apps-caret { transform: rotate(90deg); }
.sb-apps { display: flex; flex-direction: column; gap: 1px; padding: 0 8px; overflow-y: auto; }
.sb-apps-section.collapsed .sb-apps { display: none; }
.sb-app-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 7px 12px; border-radius: var(--radius-xs);
  color: var(--text-secondary); font-size: 13px;
  transition: all .15s; text-align: left;
}
.sb-app-item:hover { background: var(--bg-hover); color: var(--text); }
.sb-app-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }

/* 应用 iframe 容器 */
.apps-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.apps-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
}
.apps-title { flex: 1; text-align: center; font-size: 14px; font-weight: 800; color: var(--text); }
.apps-iframe {
  flex: 1; width: 100%; border: none; background: #fff;
}

/* ===== 图片预览 ===== */
.img-preview {
  position: relative; display: inline-block;
  margin-bottom: 8px; max-width: 180px;
}
.img-preview img {
  max-width: 180px; max-height: 120px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--accent);
  display: block;
}
.img-prev-del {
  position: absolute; top: -8px; right: -8px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #d9534f; color: #fff;
  font-size: 13px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
/* ===== 语音按钮（录音中） ===== */
.mic-btn.recording {
  background: #d9534f !important; color: #fff !important;
  animation: micPulse 1s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217,83,79,.5); }
  50% { box-shadow: 0 0 0 8px rgba(217,83,79,0); }
}

/* ==================== Markdown 渲染样式 ==================== */
.msg-bubble { line-height: 1.75; }
.md-p { margin: 0 0 8px; }
.md-p:last-child { margin-bottom: 0; }
.md-gap { height: 8px; }
.md-h { font-weight: 800; margin: 12px 0 6px; line-height: 1.4; }
.md-h1 { font-size: 1.18em; }
.md-h2 { font-size: 1.1em; }
.md-h3 { font-size: 1.04em; }
.md-h4 { font-size: 1em; }
.md-h:first-child { margin-top: 0; }
.md-list { margin: 6px 0 10px 20px; padding: 0; }
.md-list li { margin: 4px 0; line-height: 1.7; }
.md-quote {
  border-left: 3px solid var(--accent);
  padding: 4px 10px; margin: 8px 0;
  color: var(--text-secondary); background: var(--bg-hover);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}
.md-code {
  background: rgba(0,0,0,.06); border: 1px solid var(--border);
  border-radius: var(--radius-xs); padding: 10px 12px;
  margin: 8px 0; overflow-x: auto;
  font-family: var(--mono); font-size: .88em; line-height: 1.6;
  white-space: pre; max-width: 100%;
}
[data-theme="dark"] .md-code { background: rgba(0,0,0,.35); }
.msg-user .md-code { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.25); }
.md-inline-code {
  background: rgba(0,0,0,.07); padding: 1px 5px;
  border-radius: 4px; font-family: var(--mono); font-size: .9em;
}
[data-theme="dark"] .md-inline-code { background: rgba(255,255,255,.12); }
.msg-user .md-inline-code { background: rgba(255,255,255,.2); }
.md-hr { height: 1px; background: var(--border); margin: 12px 0; }
.md-table-wrap { overflow-x: auto; margin: 8px 0; max-width: 100%; }
.md-table { border-collapse: collapse; font-size: .92em; width: auto; min-width: 100%; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md-table th { background: var(--bg-hover); font-weight: 800; }
.md-cursor { color: var(--accent); font-weight: 800; animation: blink 1s infinite; }
.md-p strong, .md-list strong { font-weight: 800; }

/* ===== 模型能力标签 chip ===== */
.mc-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.mc-tag {
  font-size: 10px; font-weight: 700; padding: 2px 7px;
  border-radius: 10px; line-height: 1.5;
  border: 1px solid transparent;
}
.t-code   { background: #e3f2fd; color: #1565c0; border-color: #bbdefb; }
.t-fast   { background: #e8f5e9; color: #2e7d32; border-color: #c8e6c9; }
.t-vision { background: #f3e5f5; color: #6a1b9a; border-color: #e1bee7; }
.t-img    { background: #fff3e0; color: #e65100; border-color: #ffe0b2; }
.t-aigc   { background: #fce4ec; color: #ad1457; border-color: #f8bbd0; }
.t-reason { background: #e0f7fa; color: #00695c; border-color: #b2ebf2; }
.t-long   { background: #ede7f6; color: #4527a0; border-color: #d1c4e9; }
.t-cn     { background: #ffebee; color: #c62828; border-color: #ffcdd2; }
.t-gen    { background: #eceff1; color: #455a64; border-color: #cfd8dc; }
.t-agent  { background: #fffde7; color: #f57f17; border-color: #fff9c4; }
.t-vid    { background: #e1f5fe; color: #0277bd; border-color: #b3e5fc; }
.t-ocr    { background: #f1f8e9; color: #558b2f; border-color: #dcedc8; }
.t-math   { background: #e8eaf6; color: #283593; border-color: #c5cae9; }
[data-theme="dark"] .mc-tag { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.15); }
[data-theme="dark"] .t-code   { color: #90caf9; }
[data-theme="dark"] .t-fast   { color: #a5d6a7; }
[data-theme="dark"] .t-vision { color: #ce93d8; }
[data-theme="dark"] .t-img    { color: #ffcc80; }
[data-theme="dark"] .t-aigc   { color: #f48fb1; }
[data-theme="dark"] .t-reason { color: #80cbc4; }
[data-theme="dark"] .t-long   { color: #b39ddb; }
[data-theme="dark"] .t-cn     { color: #ef9a9a; }
[data-theme="dark"] .t-gen    { color: #b0bec5; }
[data-theme="dark"] .t-agent  { color: #fff59d; }
[data-theme="dark"] .t-vid    { color: #81d4fa; }
[data-theme="dark"] .t-ocr    { color: #c5e1a5; }
[data-theme="dark"] .t-math   { color: #9fa8da; }

/* ===== AIGC 创作工作台 ===== */
.aigc-container { flex: 1; padding: 24px 28px; overflow-y: auto; }
.aigc-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.aigc-header h2 { font-size: 20px; font-weight: 800; }
.aigc-badge {
  font-size: 11px; padding: 4px 12px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.aigc-badge.pro { background: linear-gradient(135deg, #d4f4dd, #b8e6c8); color: #1a8b3e; }
.aigc-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.aigc-tab {
  padding: 8px 16px; font-size: 13px; font-weight: 700;
  color: var(--text-secondary); border-bottom: 2px solid transparent;
  transition: all .15s; border-radius: var(--radius-xs) var(--radius-xs) 0 0;
}
.aigc-tab:hover { background: var(--bg-hover); color: var(--text); }
.aigc-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.aigc-pane { max-width: 820px; }
.aigc-input {
  width: 100%; padding: 12px 14px; margin-bottom: 10px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  outline: none; font-size: 14px; font-family: inherit;
  resize: vertical; transition: border-color .15s;
}
.aigc-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.aigc-input::placeholder { color: var(--text-muted); }
.aigc-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.aigc-sel {
  padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; font-weight: 700; outline: none;
}
.aigc-sel:focus { border-color: var(--accent); }
.aigc-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 22px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #7c5cff);
  color: #fff; font-size: 13px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(59,111,224,.25);
  transition: all .15s;
}
.aigc-btn:hover { opacity: .92; transform: translateY(-1px); }
.aigc-btn:active { transform: translateY(1px); }
.aigc-btn:disabled { opacity: .5; cursor: not-allowed; }
.aigc-result { min-height: 60px; }
.aigc-hint { font-size: 12px; color: var(--text-muted); padding: 20px; text-align: center; }
.aigc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.aigc-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
  box-shadow: var(--shadow); transition: all .15s;
}
.aigc-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.aigc-card img { width: 100%; display: block; background: var(--bg-input); }
.aigc-card .ac-body { padding: 8px 10px; }
.aigc-card .ac-copy { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.aigc-card .ac-page { font-size: 10px; color: var(--text-muted); font-weight: 800; }
.aigc-card .ac-dl {
  display: block; text-align: center; padding: 6px;
  font-size: 12px; color: var(--accent); font-weight: 700;
  border-top: 1px solid var(--border);
}
.aigc-loading {
  display: flex; align-items: center; gap: 8px;
  padding: 24px; color: var(--text-muted); font-size: 13px;
}

/* ===== 专家/技能卡片 ===== */
.exp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.exp-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
  box-shadow: var(--shadow); transition: all .15s; cursor: pointer;
  position: relative;
}
.exp-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.exp-card.active { border-color: var(--accent); background: var(--accent-soft); }
.ec-icon { font-size: 24px; margin-bottom: 6px; }
.ec-name { font-size: 14px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.ec-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.55; }
.ec-meta { font-size: 10px; color: var(--text-muted); margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.ec-tag {
  background: var(--bg-hover); padding: 2px 7px; border-radius: 8px; font-weight: 700;
}
.ec-actions { display: flex; gap: 6px; margin-top: 10px; }
.ec-btn {
  flex: 1; padding: 5px 8px; border-radius: var(--radius-xs);
  font-size: 11px; font-weight: 700; text-align: center;
  background: var(--bg-hover); color: var(--text-secondary);
  transition: all .15s;
}
.ec-btn:hover { background: var(--accent); color: #fff; }
.ec-del { flex: 0 0 auto; background: transparent; color: #c44; font-size: 14px; padding: 5px 8px; }
.ec-del:hover { background: #fce8e8; color: #c44; }
/* 分类筛选 chip */
.cat-chip {
  padding: 5px 14px; border-radius: 14px; font-size: 12px; font-weight: 700;
  background: var(--bg-hover); color: var(--text-secondary);
  cursor: pointer; transition: all .15s; border: 1px solid transparent;
}
.cat-chip:hover { border-color: var(--accent); }
.cat-chip.active { background: var(--accent); color: #fff; }
.cfg-label {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--text-secondary); margin: 12px 0 4px;
}

/* ===== 灵感墙（AIGC 页色彩化） ===== */
.aigc-inspire { margin-bottom: 18px; }
.ai-label {
  font-size: 12px; font-weight: 800; color: var(--text-muted);
  margin-bottom: 8px; display: flex; align-items: center; gap: 6px;
}
.ai-label::before { content: ''; width: 14px; height: 3px; border-radius: 2px; background: linear-gradient(90deg, #5b8cff, #7c5cff, #ff6b9d); }
.ai-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ai-cell {
  position: relative; border-radius: var(--radius-sm); overflow: hidden;
  cursor: pointer; aspect-ratio: 1; border: 1px solid var(--border);
  transition: all .25s;
}
.ai-cell img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s; }
.ai-cell:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-3px); }
.ai-cell:hover img { transform: scale(1.08); }
.ai-cell::after {
  content: attr(data-tip); position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.75));
  color: #fff; font-size: 10px; padding: 14px 8px 6px; opacity: 0;
  transition: opacity .25s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-cell:hover::after { opacity: 1; }

/* ===== 集梦画布 ===== */
.dream-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.dream-canvas-wrap {
  background: linear-gradient(135deg, #0b0e1a, #151a30, #0b0e1a);
  background-size: 300% 300%;
  animation: dreamBg 12s ease infinite;
  border-radius: var(--radius); padding: 16px; margin: 10px 0;
  display: flex; justify-content: center;
}
@keyframes dreamBg { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.dream-stage {
  width: min(420px, 100%); aspect-ratio: 3/4;
  border-radius: 10px; overflow: hidden; position: relative;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  background: #111;
}
.dream-fx { width: 100%; height: 100%; position: relative; overflow: hidden; }
.dream-fx img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dream-text {
  position: absolute; left: 0; right: 0; bottom: 12%;
  text-align: center; font-weight: 900; letter-spacing: 2px;
  font-size: clamp(18px, 4vw, 30px); text-shadow: 0 2px 12px rgba(0,0,0,.7);
  pointer-events: none;
}
/* 动效模板 */
.dream-fx.fx-kenburns img { animation: fxKen 12s ease-in-out infinite alternate; }
@keyframes fxKen { 0% { transform: scale(1) translate(0,0); } 100% { transform: scale(1.18) translate(2%, -2%); } }
.dream-fx.fx-neon img { animation: fxNeon 3s ease-in-out infinite; }
@keyframes fxNeon { 0%,100% { filter: brightness(1) saturate(1); } 50% { filter: brightness(1.35) saturate(1.4) hue-rotate(12deg); } }
.dream-fx.fx-scan::after {
  content: ''; position: absolute; left: -60%; top: 0; bottom: 0; width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  animation: fxScan 3s ease-in-out infinite;
}
@keyframes fxScan { 0% { left: -60%; } 100% { left: 120%; } }
.dream-fx.fx-tilt3d img { animation: fxTilt 5s ease-in-out infinite; }
@keyframes fxTilt { 0%,100% { transform: perspective(800px) rotateY(-4deg) rotateX(2deg) scale(1.02); } 50% { transform: perspective(800px) rotateY(4deg) rotateX(-2deg) scale(1.04); } }
.dream-fx.fx-bounce img { animation: fxBounce 2.4s ease-in-out infinite; }
@keyframes fxBounce { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-14px) scale(1.03); } }
.dream-fx.fx-particle .dream-text { animation: none; }
.dream-fx.fx-particle::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(circle at 20% 30%, rgba(255,255,255,.6) 1px, transparent 1.5px),
    radial-gradient(circle at 70% 60%, rgba(255,215,0,.6) 1px, transparent 1.5px),
    radial-gradient(circle at 40% 80%, rgba(91,140,255,.6) 1px, transparent 1.5px);
  background-size: 120px 120px, 160px 160px, 100px 100px;
  animation: fxParticle 8s linear infinite;
}
@keyframes fxParticle { 0% { background-position: 0 0, 0 0, 0 0; } 100% { background-position: 0 600px, 0 800px, 0 500px; } }
.dream-fx.fx-water img { animation: fxWater 6s ease-in-out infinite; }
@keyframes fxWater { 0%,100% { transform: scale(1) rotate(0); filter: blur(0); } 50% { transform: scale(1.06) rotate(1.2deg); filter: blur(1.5px) contrast(1.1); } }
.dream-fx.fx-typewriter .dream-text { overflow: hidden; white-space: nowrap; border-right: 2px solid currentColor; animation: fxType 3.5s steps(30) infinite; }
@keyframes fxType { 0% { width: 0; } 60%,100% { width: 100%; } }

/* ===== 内测登录门禁 ===== */
body.auth-locked .sidebar,
body.auth-locked .main-area,
body.auth-locked .footer {
  display: none !important;
}
body.auth-locked .login-page { z-index: 9999; }
.login-page.force { backdrop-filter: none; }
.login-page.force::before { background: rgba(0,0,0,.55); }

/* ===== AIGC 创作工厂 v2（大厂氛围） ===== */
.factory { position: relative; z-index: 1; flex: 1; padding: 24px 28px; overflow-y: auto; }
.factory-bg {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 15% 10%, rgba(91,140,255,.14), transparent 55%),
    radial-gradient(ellipse at 85% 20%, rgba(124,92,255,.12), transparent 55%),
    radial-gradient(ellipse at 50% 90%, rgba(255,107,157,.08), transparent 60%),
    var(--bg);
}
.factory-bg::after {
  content: ''; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 42px 42px;
}
.factory-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 18px; position: relative; z-index: 1;
}
.factory-title {
  font-size: 24px; font-weight: 900; line-height: 1.3;
  background: linear-gradient(90deg, var(--text), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.factory-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.factory-tabs {
  display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap;
  position: relative; z-index: 1;
}
.factory-tab {
  padding: 9px 16px; border-radius: 12px; font-size: 13px; font-weight: 800;
  color: var(--text-secondary); background: var(--bg-card);
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .2s; box-shadow: var(--shadow-sm);
}
.factory-tab:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--text); }
.factory-tab.active {
  background: linear-gradient(135deg, #3b6fe0, #7c5cff); color: #fff;
  border-color: transparent; box-shadow: 0 6px 18px rgba(91,140,255,.35);
}
.factory-pane { position: relative; z-index: 1; }
.f-grid { display: grid; grid-template-columns: 340px 1fr; gap: 18px; }
@media (max-width: 900px) { .f-grid { grid-template-columns: 1fr; } }
.f-panel {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; box-shadow: var(--shadow-md);
  align-self: start;
}
.f-prompt { min-height: 110px; }
.f-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.f-chip {
  padding: 4px 12px; border-radius: 14px; font-size: 11px; font-weight: 700;
  background: var(--bg-hover); color: var(--text-secondary);
  cursor: pointer; transition: all .15s; border: 1px solid transparent;
}
.f-chip:hover { border-color: var(--accent); color: var(--text); }
.f-chip.active { background: var(--accent); color: #fff; }
.f-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.f-row .aigc-sel { flex: 1; min-width: 130px; }
.factory-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 11px 22px; border-radius: 12px;
  background: linear-gradient(135deg, #3b6fe0, #7c5cff); color: #fff;
  font-size: 13px; font-weight: 800; border: none;
  box-shadow: 0 4px 14px rgba(91,140,255,.35);
  transition: all .2s; cursor: pointer;
}
.factory-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(91,140,255,.45); }
.factory-btn:active { transform: translateY(1px); }
.factory-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.factory-btn.ghost {
  background: var(--bg-hover); color: var(--text-secondary);
  box-shadow: none; border: 1px solid var(--border);
}
.factory-btn.ghost:hover { color: var(--text); }
.f-canvas {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; min-height: 420px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; box-shadow: var(--shadow-md); position: relative;
}
.f-canvas.dark { background: linear-gradient(135deg, #0b0e1a, #151a30); }
.f-canvas .result-img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 8px; animation: imgIn .4s ease;
}
@keyframes imgIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.f-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 40px; opacity: .6; }
.f-note { font-size: 11px; color: var(--text-muted); margin-top: 10px; line-height: 1.6; }
.f-canvas .f-loading {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: rgba(10,11,16,.75); backdrop-filter: blur(4px);
  color: #fff; z-index: 5;
}
.f-canvas .f-loading .ring {
  width: 54px; height: 54px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.15);
  border-top-color: #5b8cff;
  animation: ring 0.9s linear infinite;
}
@keyframes ring { to { transform: rotate(360deg); } }
.f-canvas .f-loading .bar {
  width: 180px; height: 4px; border-radius: 2px; overflow: hidden;
  background: rgba(255,255,255,.12);
}
.f-canvas .f-loading .bar::after {
  content: ''; display: block; width: 40%; height: 100%;
  background: linear-gradient(90deg, #5b8cff, #7c5cff);
  animation: bar 1.2s ease-in-out infinite;
}
@keyframes bar { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
.f-canvas .f-loading .txt { font-size: 12px; letter-spacing: 1px; color: rgba(255,255,255,.7); }
.f-canvas .f-dl {
  position: absolute; right: 12px; bottom: 12px;
  padding: 6px 14px; border-radius: 10px; font-size: 12px; font-weight: 700;
  background: rgba(0,0,0,.6); color: #fff; backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.2); z-index: 3;
  transition: all .15s;
}
.f-canvas .f-dl:hover { background: var(--accent); }
/* 漫剧网格 */
.manga-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; width: 100%; padding: 10px; }
.manga-cell {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
}
.manga-cell img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.manga-cell .mc-line {
  padding: 6px 10px; font-size: 12px; color: var(--text); line-height: 1.5;
  border-top: 1px solid var(--border); font-weight: 600;
}
.manga-cell .mc-page {
  position: absolute; top: 8px; left: 8px; width: 24px; height: 24px;
  background: rgba(0,0,0,.7); color: #fff; border-radius: 50%;
  font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.manga-cell { position: relative; }
/* 文案结果 */
.copy-result {
  width: 100%; padding: 6px; max-height: 420px; overflow-y: auto;
}
.copy-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; margin-bottom: 10px;
  font-size: 13px; line-height: 1.7; color: var(--text);
  border-left: 3px solid var(--accent);
}
.copy-card .cc-label { font-size: 11px; font-weight: 800; color: var(--accent); margin-bottom: 4px; }
/* 文生动画画布 */
#fT2aCanvas .dream-stage { width: min(360px, 90%); }

/* ===== 作品墙（本地图秒开） ===== */
.f-works { margin-top: 14px; padding: 12px 14px; border-radius: 14px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.07); }
.fw-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px; }
.fw-label::before { content: ""; width: 3px; height: 12px; border-radius: 2px;
  background: linear-gradient(180deg, #5b8cff, #7c5cff); }
.fw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.fw-cell { position: relative; border-radius: 10px; overflow: hidden; cursor: pointer;
  background: linear-gradient(135deg, #1a1d2e, #232838);
  transition: transform .18s, box-shadow .18s; }
.fw-cell:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,.35); }
.fw-cell img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
  background: linear-gradient(135deg,#1a1d2e,#232838); }
.fw-cell i { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 6px;
  font-style: normal; font-size: 10px; color: #fff; text-align: center;
  background: linear-gradient(to top, rgba(0,0,0,.75), transparent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fw-pair .fw-cell img { aspect-ratio: 1; }
.fw-manga .fw-cell img { aspect-ratio: 3/3.6; }
.fw-manga .fw-cell i { font-size: 9.5px; line-height: 1.25; white-space: normal; padding: 5px 6px; }

/* 灵感墙图片底部标题 */
.ai-cell { position: relative; }
.ai-cell img { background: linear-gradient(135deg,#1a1d2e,#232838); }
.ai-cell i { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px;
  font-style: normal; font-size: 10.5px; color: #fff; text-align: center;
  background: linear-gradient(to top, rgba(0,0,0,.7), transparent); opacity: 0;
  transition: opacity .2s; }
.ai-cell:hover i { opacity: 1; }

/* 图片加载占位（骨架闪烁） */
.f-canvas img.result-img, .f-canvas .dream-stage img {
  animation: imgIn .45s ease-out; }
@keyframes imgIn { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }
.f-canvas img, .f-works img, .ai-grid img {
  background: linear-gradient(90deg, #1c1f30 25%, #262b40 37%, #1c1f30 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ===== 工厂返回按钮 + 头部 ===== */
.factory-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.factory-head-right { display: flex; align-items: center; gap: 10px; }
.factory-back {
  padding: 9px 18px; border-radius: 10px; cursor: pointer;
  background: linear-gradient(135deg, #1c2a4a, #26365c);
  border: 1px solid rgba(120,160,255,.3);
  color: #cfdfff; font-size: 13px; font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 3px 10px rgba(0,0,0,.3);
  transition: all .18s;
}
.factory-back:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(80,120,255,.25); color: #fff; }
.factory-back:active { transform: translateY(1px); box-shadow: inset 0 2px 6px rgba(0,0,0,.3); }

/* ===== 全宽 Banner（视觉冲击） ===== */
.factory-banner {
  position: relative; margin: 14px 0 0; border-radius: 18px; overflow: hidden;
  min-height: 150px; display: flex; align-items: center;
  background: linear-gradient(120deg, #0d1b3e 0%, #16245c 45%, #3b1a5e 100%);
  border: 1px solid rgba(130,160,255,.18);
  box-shadow: 0 10px 40px rgba(30,60,180,.25);
}
.factory-banner::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 15% 30%, rgba(90,160,255,.35), transparent 45%),
    radial-gradient(circle at 85% 70%, rgba(200,100,255,.3), transparent 45%),
    radial-gradient(circle at 50% 0%, rgba(80,220,255,.18), transparent 50%);
  animation: bannerBreath 6s ease-in-out infinite;
}
@keyframes bannerBreath {
  0%, 100% { opacity: .7; } 50% { opacity: 1; }
}
.factory-banner::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 42px 42px;
}
.factory-banner-inner { position: relative; z-index: 2; padding: 26px 30px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.factory-banner h2 { font-size: 26px; font-weight: 800; margin: 0 0 6px;
  background: linear-gradient(90deg, #fff, #9cc0ff, #e0b0ff);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.factory-banner p { font-size: 13px; color: rgba(255,255,255,.75); margin: 0; line-height: 1.6; }
.factory-banner-stats { display: flex; gap: 18px; margin-left: auto; }
.fb-stat { text-align: center; }
.fb-stat b { display: block; font-size: 22px; color: #ffd76a; }
.fb-stat span { font-size: 11px; color: rgba(255,255,255,.6); }

/* ===== 新增动效模板（glitch/hue/zoompan/glowline） ===== */
.dream-fx.fx-glitch img { animation: fg-glitch 1.6s steps(2) infinite; }
@keyframes fg-glitch {
  0%, 92%, 100% { filter: none; transform: none; }
  93% { filter: hue-rotate(90deg) contrast(1.4); transform: translateX(-4px); }
  95% { filter: invert(.8); transform: translateX(4px); }
  97% { filter: hue-rotate(-90deg) contrast(1.3); transform: translateX(-2px); }
}
.dream-fx.fx-hue img { animation: fg-hue 4s ease-in-out infinite; }
@keyframes fg-hue {
  0%, 100% { filter: hue-rotate(0) saturate(1); }
  50% { filter: hue-rotate(120deg) saturate(1.5); }
}
.dream-fx.fx-zoompan img { animation: fg-zp 12s ease-in-out infinite alternate; }
@keyframes fg-zp {
  0% { transform: scale(1.15) translateX(-3%); }
  100% { transform: scale(1.05) translateX(3%); }
}
.dream-fx.fx-glowline::after {
  content: ""; position: absolute; inset: -2px; border-radius: 12px; pointer-events: none;
  background: linear-gradient(120deg, transparent 20%, rgba(255,215,0,.55) 50%, transparent 80%);
  background-size: 260% 100%;
  animation: fg-gl 2.6s linear infinite;
  mix-blend-mode: screen;
}
@keyframes fg-gl { 0% { background-position: 120% 0; } 100% { background-position: -120% 0; } }

/* ===== 在线 PS iframe ===== */
.f-ps-wrap { width: 100%; }
.f-ps-frame { width: 100%; height: 640px; border: 1px solid rgba(255,255,255,.12); border-radius: 14px; background: #222; }
@media (max-width: 768px) { .f-ps-frame { height: 460px; } }

/* ===== 示例图灯箱（大图预览） ===== */
.lightbox { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; }
.lightbox.hidden { display: none; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(5,8,18,.82); backdrop-filter: blur(10px); animation: lbFade .2s; }
@keyframes lbFade { from { opacity: 0; } to { opacity: 1; } }
.lb-box {
  position: relative; z-index: 2; width: min(560px, 92vw);
  background: linear-gradient(160deg, #12162a, #1a1f38);
  border: 1px solid rgba(120,160,255,.25); border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
  padding: 16px; animation: lbPop .25s ease-out;
}
@keyframes lbPop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.lb-close {
  position: absolute; top: -12px; right: -12px; width: 32px; height: 32px; border-radius: 50%;
  background: #2a3150; color: #fff; font-size: 16px; cursor: pointer; z-index: 3;
  border: 1px solid rgba(255,255,255,.2); box-shadow: 0 4px 12px rgba(0,0,0,.4);
  transition: all .15s;
}
.lb-close:hover { background: #e05555; transform: rotate(90deg); }
.lb-stage { position: relative; width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #0c0f1e; }
.lb-stage img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lb-meta { padding: 12px 6px 2px; }
.lb-title { font-size: 15px; font-weight: 700; color: #e8ecff; margin-bottom: 10px; }
.lb-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.lb-actions .factory-btn { text-decoration: none; }

/* ===== 示例动画高亮 ===== */
.fw-cell.demo-active { outline: 2px solid #ffd76a; outline-offset: 2px; box-shadow: 0 0 18px rgba(255,215,106,.35); }
.fw-demo .fw-cell img { aspect-ratio: 1; }

/* ===== 问候语淡入动画 ===== */
.greet-anim { animation: greetIn .9s ease-out; }
@keyframes greetIn {
  from { opacity: 0; transform: translateY(10px); filter: blur(3px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

/* ===== 问候语字体（黑色为主，字号营造层次） ===== */
.welcome-greeting .bi > .zh {
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--text);
}
.welcome-greeting .bi > .en {
  color: var(--text-secondary);
  font-weight: 500;
}
/* 女性：字号微大、柔和圆润 */
.welcome-greeting.greet-style-f .bi > .zh {
  font-size: 1.12em;
  letter-spacing: 3px;
}
.welcome-greeting.greet-style-f .bi > .en {
  font-size: .82em;
  letter-spacing: 1px;
}
/* 中二：超大字号 + 超粗 + 宽字距，制造压迫感 */
.welcome-greeting.greet-style-m .bi > .zh {
  font-size: 1.55em;
  font-weight: 1000;
  letter-spacing: 6px;
  transform: scaleX(1.02);
}
.welcome-greeting.greet-style-m .bi > .en {
  font-size: .88em;
  letter-spacing: 3px;
}
/* 中性：标准 */
.welcome-greeting.greet-style-n .bi > .zh { font-size: 1em; }

/* ===== Agent Runner 智能体运行可视化 ===== */
.agent-runner {
  position: fixed; right: 24px; bottom: 24px; z-index: 900;
  width: 460px; height: 500px;
  background: rgba(8, 10, 22, .62);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(120, 160, 255, .25);
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .08);
  padding: 0;
  display: flex; flex-direction: column;
  animation: runnerIn .35s ease-out;
}
.agent-runner.hidden { display: none; }
.agent-runner.run-success { animation: runnerSuccess .6s ease-out; }
.agent-runner.run-fade { animation: runnerFade .5s ease-in forwards; }
@keyframes runnerIn { from { opacity: 0; transform: translateY(20px) scale(.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes runnerFade { to { opacity: 0; transform: translateY(20px) scale(.95); } }
@keyframes runnerSuccess { 0%, 100% { box-shadow: 0 18px 60px rgba(0,0,0,.55); } 50% { box-shadow: 0 0 0 2px #5be5a4, 0 18px 80px rgba(91, 229, 164, .55); } }

.runner-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,.06);
  font-size: 12px; color: rgba(255,255,255,.85);
}
.rh-dot { width: 8px; height: 8px; border-radius: 50%;
  background: #5be5a4; box-shadow: 0 0 10px #5be5a4;
  animation: rhPulse 1.4s ease-in-out infinite; }
@keyframes rhPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.7); } }
.rh-text { font-weight: 700; letter-spacing: 1px; }
.rh-step { margin-left: auto; opacity: .55; font-size: 11px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rh-close {
  width: 24px; height: 24px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.06); color: #fff; font-size: 14px; line-height: 22px; padding: 0;
  transition: all .15s;
}
.rh-close:hover { background: rgba(224, 85, 85, .8); transform: rotate(90deg); }

.runner-svg { flex: 1; width: 100%; height: 100%; display: block; }
.runner-svg .rnode { cursor: default; }
.runner-svg .rnode-circle { transition: all .25s; }
.runner-svg .rnode.active .rnode-circle {
  fill: url(#activeGrad) !important;
  filter: drop-shadow(0 0 10px #ffd76a);
  transform-origin: center;
  transform-box: fill-box;
}
.runner-svg .rnode.success .rnode-circle {
  fill: url(#successGrad) !important;
  filter: drop-shadow(0 0 12px #5be5a4);
}
.runner-svg .rnode.running .rnode-circle {
  fill: url(#runGrad) !important;
  filter: drop-shadow(0 0 14px #5b8cff);
  animation: rNodePulse 1.2s ease-in-out infinite;
}
@keyframes rNodePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.runner-svg .rnode-text { fill: #fff; font-size: 11px; font-weight: 700; text-anchor: middle; pointer-events: none; }
.runner-svg .rnode-sub { fill: rgba(255,255,255,.55); font-size: 8px; text-anchor: middle; pointer-events: none; }
.runner-svg .rcenter-text { fill: #fff; font-size: 16px; font-weight: 900; text-anchor: middle; pointer-events: none; letter-spacing: 1.5px; }
.runner-svg .rcenter-sub { fill: rgba(180,200,255,.7); font-size: 8px; text-anchor: middle; letter-spacing: 2px; pointer-events: none; }

.runner-svg .redge { stroke: rgba(120,160,255,.15); stroke-width: 1; fill: none; }
.runner-svg .redge.active { stroke: #ffd76a; stroke-width: 1.5; stroke-dasharray: 6 4; animation: redgeFlow 1.2s linear infinite; }
.runner-svg .redge.running { stroke: #5b8cff; stroke-width: 1.8; stroke-dasharray: 8 3; animation: redgeFlow .8s linear infinite; filter: drop-shadow(0 0 4px #5b8cff); }
@keyframes redgeFlow { to { stroke-dashoffset: -20; } }

.runner-stats {
  display: flex; justify-content: space-around;
  padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.06);
  background: rgba(0,0,0,.2);
}
.rs-item { display: flex; align-items: center; gap: 6px; font-size: 11px; color: rgba(255,255,255,.7); }
.rs-dot { width: 6px; height: 6px; border-radius: 50%; }
.rs-dot.dot-think { background: #c084fc; }
.rs-dot.dot-tool { background: #ffd76a; }
.rs-dot.dot-model { background: #5b8cff; }
.rs-n { color: #fff; font-weight: 700; min-width: 14px; text-align: right; }
.rs-l { opacity: .65; }

@media (max-width: 768px) {
  .agent-runner { right: 12px; left: 12px; bottom: 12px; width: auto; height: 60vh; }
}

/* ==================== FOOTER ==================== */
.footer { text-align: center; padding: 6px; font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.dev-credit { font-weight: 600; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); box-shadow: var(--shadow); z-index: 200; transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.4);
    z-index: 150; display: none;
  }
  .sidebar-overlay.show { display: block; }
  .topbar-menu { display: block; }
  .welcome-greeting { font-size: 22px; }
  .welcome-sub { font-size: 18px; }
  .welcome-mascot, .chat-mascot { width: 80px; top: -44px; right: 12px; }
  .login-card { padding: 28px 22px 22px; }
}
