/* ===== 现代 AI 生图工作台 ===== */
body{background:#f2f3f4}
.app{height:100dvh;padding:0;gap:0;background:#f2f3f4}

/* 左侧：对话式创作栏 */
.sidebar{
  width:390px;border:0;border-right:1px solid var(--border);border-radius:0;
  background:#fff;box-shadow:none;overflow:hidden;transition:width .28s ease,opacity .2s;
}
.sidebar::before{display:none}
.sidebar.collapsed{width:0;margin-left:0;border-right:0;opacity:0}
.sidebar-head{
  height:68px;padding:0 12px 0 18px;border-bottom:1px solid var(--border-soft);
  box-shadow:none;flex-shrink:0;gap:10px;
}
.project-brand{display:flex;align-items:center;gap:9px;min-width:0}
.sidebar-brand{flex:1;overflow:hidden}
.project-logo{width:30px;height:30px;border-radius:9px;object-fit:cover;flex-shrink:0}
.project-copy{display:flex;flex-direction:column;gap:3px;min-width:0;overflow:hidden}
.project-copy b{font-size:12px;line-height:1;font-weight:720;letter-spacing:.5px;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.project-copy span{font-size:8px;line-height:1;letter-spacing:1.5px;color:var(--text-dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.head-btn{width:30px;height:30px;border-radius:9px;border:1px solid transparent}
.head-btn svg{width:14px;height:14px}
.head-btn:hover{background:#f3f4f5;border-color:#e6e9eb;box-shadow:none}

.composer-kicker{display:block;font-size:9px;font-weight:700;letter-spacing:1.7px;color:#9aa1a6;line-height:1}
.sidebar-body{padding:16px 16px 12px;background:#fafafa}
.sidebar-empty{margin:auto;padding:28px 10px;display:flex;flex-direction:column;align-items:center;gap:7px}
.sidebar-empty b{font-size:13px;font-weight:620;color:var(--text-mid)}
.sidebar-empty > span{font-size:11.5px;color:var(--text-dim)}
.history-loading{margin:auto;padding:28px 10px;display:flex;flex-direction:column;align-items:center;gap:7px;text-align:center}
.history-loading[hidden]{display:none!important}
.history-loading b{font-size:13px;font-weight:620;color:var(--text-mid)}
.history-loading-spinner{width:24px;height:24px;margin-bottom:7px;border:2px solid #dfe4e7;border-top-color:#606b72;border-radius:50%;animation:historyLoadingSpin .8s linear infinite}
@keyframes historyLoadingSpin{to{transform:rotate(360deg)}}
.empty-orb{width:54px;height:54px;border-radius:18px;background:#fff;border:1px solid var(--border);display:grid;place-items:center;margin-bottom:7px}
.empty-orb span{width:18px;height:18px;border-radius:6px;background:linear-gradient(145deg,#c6cdd1,#5c666c);box-shadow:8px 8px 0 -5px #d9dde0,-8px -8px 0 -5px #eef0f1;transform:rotate(45deg)}

.sidebar-compose-slot{padding:0 14px 10px;background:#fafafa;flex-shrink:0;z-index:25}
.sidebar-expand{top:18px;left:18px;width:34px;height:34px;background:#fff;border-color:var(--border);border-radius:10px;box-shadow:0 4px 18px rgba(35,42,46,.09)}

/* 左侧输入框 */
.sidebar-compose-slot .bottom-area{display:block}
.sidebar-compose-slot .composer{width:100%;padding:13px;border:1px solid #dfe3e6;border-radius:16px;background:#fff;box-shadow:0 8px 28px rgba(37,43,47,.08);gap:9px}
.composer::before{display:none}
.composer-head{display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--border-soft);padding:0 1px 9px}
.composer-head > div{display:flex;align-items:center;gap:8px}
.composer-head b{font-size:11.5px;font-weight:650}
.composer-collapse-btn{width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;color:#8e969b;transition:background-color .14s,color .14s}
.composer-collapse-btn:hover{background:#f1f3f4;color:#3f474c}
.composer-collapse-btn svg{width:15px;height:15px;transition:transform .18s ease}
.composer.collapsed{gap:0;padding-bottom:13px}
.composer.collapsed .composer-head{padding-bottom:0;border-bottom-color:transparent}
.composer.collapsed > :not(.composer-head){display:none!important}
.composer.collapsed .composer-collapse-btn svg{transform:rotate(180deg)}
.composer-input{min-height:122px;max-height:176px;font-size:13px;line-height:1.55;padding:2px 1px}
.composer-bar{padding:9px 0 0;gap:4px;flex-wrap:wrap}
.bar-btn{height:30px;padding:0 8px;border-radius:8px;font-size:11px}
.bar-btn:hover{background:#f2f4f5;box-shadow:none}
.ref-upload-btn{width:31px;background:#f2f4f5;box-shadow:none}
.ref-upload-btn svg{width:17px;height:17px}
.clear-prompt-btn{width:30px}
.char-counter{font-size:9px;margin-right:3px}
.ref-row{max-height:62px;overflow-y:auto}
.ref-thumb,.ref-add{width:46px;height:46px;border-radius:9px}
.more-pop{left:auto;right:-60px;max-height:62vh}
.error-msg{margin-bottom:0}

/* 左侧：视觉画布 */
.main{padding:0;gap:0;background:#f2f3f4}
.status{height:30px;padding:0 10px;border-radius:9px;background:#fff;border:1px solid #e0e3e5;font-size:10.5px}

.result-panel{margin:0;flex:1;border:0;border-radius:0;background:#f7f8f8;box-shadow:none}
.result-panel::before,.result-panel::after{display:none}
.result-body{padding:28px;background-image:radial-gradient(circle at center,rgba(255,255,255,.96) 0,rgba(247,248,248,.92) 44%,rgba(241,243,244,.98) 100%)}
.result-body::before{content:"";position:absolute;inset:0;pointer-events:none;opacity:.36;background-image:linear-gradient(#dfe3e5 1px,transparent 1px),linear-gradient(90deg,#dfe3e5 1px,transparent 1px);background-size:32px 32px;mask-image:radial-gradient(circle at center,#000,transparent 78%)}
.empty{position:relative;z-index:1;gap:11px}
.empty .empty-icon{width:68px;height:68px;border-radius:22px;background:#fff;border:1px solid #dfe3e5;box-shadow:0 12px 38px rgba(49,58,63,.07)}
.empty b{font-size:16px;color:#4d555a}
.empty span{font-size:12px}
.empty-chips{display:flex;gap:6px;margin-top:4px}
.empty-chips i{font-style:normal;font-size:9px;color:#838b90;padding:5px 8px;border-radius:7px;background:#fff;border:1px solid #e4e7e9}
.loading{border-radius:17px}
.generation-progress{width:min(440px,58vw)}
.result-image{inset:26px;border-radius:16px;box-shadow:0 18px 60px rgba(34,42,46,.09)}
.result-image .result-foreground{padding:10px}
.image-actions{bottom:42px;right:42px}

/* 原 main 中占位的容器已迁移到侧栏 */
.main > .bottom-area{display:none}

@media(max-width:1100px){
  .sidebar{width:350px}
  .sidebar-compose-slot{padding:0 11px 9px}
  .bar-btn{padding:0 7px}
  .bar-btn .btn-label{display:none}
}

/* 画布居左，对话创作栏居右 */
.main{order:1}
.sidebar-expand{order:2;left:auto;right:18px}
.sidebar{
  order:3;border-right:0;border-left:1px solid var(--border);
  transition:width .28s ease,opacity .2s;
}
.sidebar.collapsed{width:0;margin-left:0}
.sidebar .pop{left:auto;right:0}
.model-settings-pop{
  width:380px;height:440px;max-width:calc(100vw - 34px);max-height:min(76vh,440px);padding:14px;
  overflow:hidden;grid-template-rows:auto auto auto minmax(0,1fr);
}
.model-settings-pop.open{display:grid}
.model-settings-scroll{
  min-height:0;margin-top:4px;padding-right:5px;overflow-y:auto;overscroll-behavior:contain;
  scrollbar-width:thin;scrollbar-color:#cfd4d7 transparent;
}
.model-settings-pop.has-mj-settings{height:440px;max-height:min(76vh,440px)}
.model-settings-scroll::-webkit-scrollbar{width:5px}
.model-settings-scroll::-webkit-scrollbar-track{background:transparent}
.model-settings-scroll::-webkit-scrollbar-thumb{background:#cfd4d7;border-radius:999px}
.model-settings-scroll::-webkit-scrollbar-thumb:hover{background:#b8bec2}
.model-tabs{
  display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px;
  padding:4px;border:1px solid var(--border-soft);border-radius:12px;background:#f3f5f6;
}
.model-tab{
  min-width:0;min-height:58px;padding:7px 3px;border:1px solid transparent;border-radius:9px;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;
  background:transparent;color:var(--text-mid);font-size:10.5px;font-weight:580;line-height:1;
  cursor:pointer;transition:background-color .14s,border-color .14s,color .14s,box-shadow .14s;
}
.model-tab svg{width:19px;height:19px;flex-shrink:0;display:block;fill:currentColor;stroke:none}
.model-tab span{overflow:hidden;max-width:100%;text-overflow:ellipsis;white-space:nowrap}
.model-tab:hover{background:#fff;color:var(--text)}
.model-tab.active{
  background:#fff;border-color:#d9dee1;color:var(--text);
  box-shadow:0 2px 7px rgba(33,39,43,.08);
}
.model-tab.active svg{color:#4f86ff}
.pop-section-label{font-size:9px;font-weight:700;letter-spacing:1.2px;color:var(--text-dim);margin:12px 3px 7px}
.model-settings-pop > .pop-section-label:first-of-type{margin-top:3px}
.model-output-section{padding-top:2px}
.setting-chip-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
.setting-chip-grid.cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}
.setting-chip{
  min-height:34px;padding:6px 8px;border:1px solid var(--border);border-radius:9px;
  background:#f7f8f9;color:var(--text-mid);font-size:11px;line-height:1.25;
  transition:background-color .14s,border-color .14s,color .14s,opacity .14s;
}
.setting-chip:hover{background:#f1f3f4;color:var(--text)}
.setting-chip.active{background:#252a2e;border-color:#252a2e;color:#fff}
#resBtn,#resPop{display:none!important}
.model-icon-btn{width:31px;padding:0;justify-content:center;background:#f2f4f5}
.model-icon-btn svg{width:16px;height:16px}
.model-icon-btn .model-cube-icon{width:18px;height:18px;color:#4f86ff;stroke-width:1.65}
.model-icon-btn:hover,.model-icon-btn.active{background:#edf3ff}
.model-icon-btn:hover .model-cube-icon,.model-icon-btn.active .model-cube-icon{color:#2f70ff}
.visually-hidden{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}

@media(max-width:820px){
  .sidebar{width:350px}
  .history-action{opacity:1}
}

@media(max-width:760px){
  body{overflow:auto}
  .app{display:block;min-height:100dvh;height:auto}
  .sidebar{position:relative;inset:auto;width:100%;height:58dvh;min-height:520px;border-left:0;border-right:0;border-top:1px solid var(--border);border-bottom:0;box-shadow:none;order:2}
  .sidebar.collapsed{width:100%;height:0;min-height:0}
  .sidebar-expand{position:fixed}
  .sidebar-head{height:56px}
  .sidebar-compose-slot{padding-bottom:10px}
  .main{height:70dvh;min-height:520px;padding:0;gap:0;order:1}
  .sidebar-head{padding-left:14px;padding-right:10px}
  .project-copy b{font-size:11.5px}
  .head-btn{width:29px;height:29px}
  .status{display:none}
  .result-panel{margin:0;border-radius:0}
  .result-image{inset:12px;border-radius:12px}
  .image-actions{bottom:24px;right:24px}
  .more-pop{right:-90px;max-width:calc(100vw - 30px)}
}
