:root {
  --blue: #159fe0;
  --blue-dark: #078bc8;
  --ink: #17212b;
  --muted: #74808c;
  --line: #e7ebef;
  --soft: #f5f7f9;
  --danger: #dc3e55;
  --shadow: 0 14px 40px rgba(18, 31, 44, .09);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--ink); background: #f4f6f8; font-size: 14px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.topbar { height: 50px; padding: 0 24px; background: #ffffff00; border-bottom: 0px solid var(--line); display: flex; align-items: stretch; gap: 18px; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; flex: none;display:none }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #31b8ee, #087fc8); box-shadow: 0 6px 14px rgba(21,159,224,.24); }
.top-actions { display: flex; gap: 10px; align-items: center; flex: none; }
.button { height: 36px; padding: 0 15px; border-radius: 8px; border: 1px solid #dce2e7; background: #fff; color: #34414d; }
.button:hover { border-color: #aebbc5; }
.button.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.button.primary:hover { background: var(--blue-dark); }
.button.small { height: 36px; }
.session-bar { min-width: 0; flex: 1; display: flex; align-items: end; gap: 4px; overflow-x: auto; overflow-y: hidden; }
.session-tabs { display: flex; height: 100%; align-items: end; gap: 3px; }
.session-tab { min-width: 132px; max-width: 220px; height: 40px; padding: 0 11px 0 15px; border: 1px solid var(--line); border-bottom: none; background: #f7f8f9; border-radius: 9px 9px 0 0; color: #5e6974; display: flex; align-items: center; gap: 9px; }
.session-tab.active { height: 44px; background: #fff; color: var(--blue-dark); box-shadow: inset 0 3px var(--blue); font-weight: 600; }
.session-tab .tab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.session-tab .tab-close { border: 0; background: transparent; color: #a5adb5; padding: 2px; opacity: 0; }
.session-tab:hover .tab-close { opacity: 1; }
.session-tab .tab-close:hover { color: var(--danger); }
.session-loading { color: #8d99a3; font-size: 13px; padding: 12px 16px; }
.add-session { width: 40px; height: 40px; margin-bottom: 0; border: 1px dashed #cdd5dc; border-bottom: 0; border-radius: 9px 9px 0 0; background: #fff; color: #66717c; font-size: 21px; }
.workspace { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 20px; padding: 20px 24px 32px; max-width: 1600px; margin: auto; }
.control-panel, .results-panel { background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 2px 8px rgba(16,35,50,.025); }
.control-panel { align-self: start; position: sticky; top: 0px; max-height: calc(100vh - 110px); overflow-y: auto; }
.panel-section { padding: 20px; border-bottom: 1px solid var(--line); }
.panel-section:last-child { border-bottom: 0; }
h1, h2, h3, p { margin-top: 0; }
h2 { font-size: 15px; margin-bottom: 14px; }
.section-heading { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.section-heading h2 { margin: 0 0 5px; }
.section-heading p { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.section-heading.compact { align-items: center; margin-bottom: 12px; }
.section-heading.compact h2 { margin: 0; }
.count { color: #9aa3ab; font-size: 12px; }
.dropzone { width: 100%; border: 1px dashed #b8c3cc; border-radius: 10px; min-height: 104px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #55616d; background: #fff; transition: .2s; outline: none; cursor: pointer; }
.dropzone:hover, .dropzone.dragging, .dropzone:focus { border-color: var(--blue); background: #f1faff; }
.dropzone strong { font-size: 13px; margin: 3px 0 5px; }
.dropzone span { color: #9aa4ad; font-size: 11px; }
.upload-icon { color: var(--blue); font-size: 23px; line-height: 1; }
.uploads { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.upload-add-card { aspect-ratio: 1.35; min-height: 0; padding: 10px; }
.upload-add-card strong { text-align: center; line-height: 1.35; }
.upload-card { min-width: 0; position: relative; }
.thumb-wrap { position: relative; aspect-ratio: 1.35; overflow: hidden; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; }
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.upload-card-actions { position: absolute; right: 5px; top: 5px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.thumb-wrap:hover .upload-card-actions, .upload-card-actions:focus-within { opacity: 1; }
.upload-card-actions button { height: 24px; min-width: 24px; padding: 0 7px; border: 0; border-radius: 6px; background: rgba(20,28,35,.76); color: #fff; font-size: 11px; }
.upload-card-actions button:hover { background: rgba(7,139,200,.92); }
.image-label { display: flex; align-items: center; gap: 5px; margin-top: 6px; }
.image-label span { color: #7f8992; font-size: 11px; flex: none; }
.image-label input { width: 100%; min-width: 0; height: 30px; border: 1px solid #dfe4e8; border-radius: 6px; padding: 0 8px; outline: none; font-size: 12px; }
.image-label input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21,159,224,.1); }
.link-button { border: 0; background: transparent; color: var(--blue-dark); padding: 0; font-size: 12px; }
.upload-section > .link-button { margin-top: 13px; }
.prompt-wrap { position: relative; }
.prompt-section { padding-bottom: 0; border-bottom: 0; }
.settings-section { padding-top: 16px; }
textarea { width: 100%; height: 132px; resize: vertical; min-height: 96px; padding: 12px 12px 28px; border: 1px solid #dce2e7; border-radius: 9px; outline: none; line-height: 1.6; }
textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21,159,224,.1); }
.char-count { position: absolute; right: 10px; bottom: 9px; color: #a4acb4; font-size: 11px; }
select { width: 100%; height: 38px; border: 1px solid #dce2e7; border-radius: 8px; background: #fff; padding: 0 10px; outline: none; }
.format-cascade { display: grid; grid-template-columns: .72fr .62fr 1.35fr; gap: 8px; margin-bottom: 16px; }
.format-cascade select { min-width: 0; padding: 0 8px; }
.model-select-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.model-select-row[hidden] { display: none; }
.model-select-row select { min-width: 0; flex: 1; }
.model-select-row button { flex: none; }
.generate-button { width: 100%; height: 44px; border: 0; border-radius: 9px; color: #fff; background: linear-gradient(100deg, #159fe0, #0c88cd); font-size: 15px; font-weight: 600; box-shadow: 0 7px 18px rgba(21,159,224,.2); }
.generate-button:hover { filter: brightness(.97); }
.generate-button:disabled { cursor: wait; opacity: .72; }
.generate-button.loading .spark { display: inline-block; animation: spin 1s linear infinite; }
.results-panel { min-height: calc(100vh - 168px); padding: 22px; }
.results-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--line); padding-bottom: 17px; }
.results-header h1 { font-size: 18px; margin-bottom: 5px; }
.results-header p { font-size: 12px; color: var(--muted); margin: 0; }
.empty-state { min-height: 480px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #8c969f; }
.empty-state[hidden] { display: none; }
.empty-art { width: 92px; height: 92px; display: grid; place-items: center; border-radius: 28px; color: var(--blue); font-size: 31px; background: linear-gradient(145deg,#edf9ff,#f7fbfd); border: 1px solid #e2f3fb; margin-bottom: 19px; }
.empty-state h3 { color: #56616c; font-size: 16px; margin-bottom: 8px; }
.empty-state p { font-size: 12px; }
.result-list { padding-top: 18px; display: flex; flex-direction: column; gap: 22px; }
.generation { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.generation-head { padding: 12px 14px; background: #fafbfc; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.generation-time { font-weight: 600; font-size: 12px; }
.generation-meta { color: #7f8a94; font-size: 11px; display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.generation-head-right { display: flex; align-items: center; justify-content: flex-end; gap: 14px; flex-wrap: wrap; }
.actual-image-info { color: #4f7588; }
.generation-download { white-space: nowrap; }
.generation-delete { color: var(--danger); white-space: nowrap; }
.generation-body { padding: 14px; }
.main-results { display: grid; gap: 12px; }
.main-results.single { grid-template-columns: minmax(0, 1fr); }
.image-result { position: relative; min-height: 240px; border-radius: 9px; overflow: hidden; background: #edf0f2; display: grid; place-items: center; cursor: zoom-in; }
.image-result img { display: block; width: 100%; max-height: 680px; object-fit: contain; pointer-events: none; background: #f0f2f3; }
.image-actions { position: absolute; right: 9px; bottom: 9px; display: flex; gap: 6px; opacity: 0; transform: translateY(4px); transition: .16s; }
.image-result:hover .image-actions { opacity: 1; transform: none; }
.icon-button { border: 0; height: 32px; padding: 0 10px; border-radius: 7px; background: rgba(17,25,32,.78); color: #fff; font-size: 12px; backdrop-filter: blur(5px); }
.placeholder { width: 100%; min-height: 360px; display: grid; place-items: center; background: linear-gradient(100deg,#eef1f3 25%,#f7f8f9 40%,#eef1f3 65%); background-size: 400% 100%; animation: shimmer 1.5s infinite; color: #8a959e; }
.waiting { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.spinner { width: 29px; height: 29px; border: 3px solid #d2eaf5; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
.generation-controls { display: flex; align-items: center; gap: 9px; padding-top: 12px; flex-wrap: wrap; }
.generation-controls select { width: 92px; height: 34px; }
.continue-button { height: 34px; border: 0; padding: 0 13px; border-radius: 7px; color: #fff; background: var(--blue); }
.continue-button:disabled { opacity: .65; cursor: wait; }
.continue-title { font-size: 12px; color: #66727c; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.continued-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.continued-grid .image-result { min-height: 130px; }
.continued-grid img { height: 100%; max-height: 310px; object-fit: cover; }
.error-box { padding: 16px 18px; border: 1px solid #f1c8ce; color: #9f2639; background: #fff6f7; border-radius: 9px; }
.error-box > strong { display: block; color: #c92f46; font-size: 15px; margin-bottom: 12px; }
.error-reason { display: grid; grid-template-columns: 68px minmax(0, 1fr); gap: 10px; align-items: start; }
.error-reason span { color: #a95a66; font-size: 12px; padding-top: 2px; }
.error-reason p { margin: 0; color: #792c38; line-height: 1.65; word-break: break-word; white-space: pre-wrap; }
.error-metadata { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0 0 78px; }
.error-metadata code { padding: 4px 7px; border-radius: 5px; background: #fbe5e8; color: #8e3b48; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; word-break: break-all; }
.error-details { margin: 12px 0 0 78px; color: #8b4a54; font-size: 12px; line-height: 1.6; }
.error-suggestion { margin: 12px 0 0 78px; padding-top: 10px; border-top: 1px solid #f4d6db; color: #8b4a54; font-size: 12px; line-height: 1.6; }
.modal-layer { position: fixed; inset: 0; z-index: 100; background: rgba(11,18,24,.55); display: grid; place-items: center; padding: 24px; backdrop-filter: blur(2px); }
.modal-layer[hidden] { display: none; }
.modal { width: min(520px, 100%); max-height: min(720px, 90vh); display: flex; flex-direction: column; background: #fff; border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.modal.wide { width: min(920px, 96vw); height: min(820px, 92vh); background: #12171b; }
.modal-layer.preview-mode { padding: 0; }
.modal-layer.preview-mode .modal.wide { width: 100vw; height: 100vh; max-height: none; border-radius: 0; }
.modal-layer.continuation-mode .modal { width: min(680px, 100%); }
.modal-layer.history-mode .modal { width: min(980px, 96vw); height: min(820px, 90vh); }
.modal-layer.history-mode .modal-body { flex: 1; min-height: 0; padding: 8px 20px 20px; }
.modal-layer.history-mode .list-row { align-items: flex-start; padding: 14px 12px; }
.modal-layer.history-mode .list-row .content { white-space: pre-wrap; overflow: visible; text-overflow: clip; line-height: 1.65; word-break: break-word; }
.modal-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.modal.wide .modal-head { border-color: #2b333a; color: #fff; }
.modal-layer.preview-mode .modal-head { position: absolute; z-index: 4; top: 0; left: 96px; right: 0; color: #fff; border: 0; background: transparent; pointer-events: none; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.modal-layer.preview-mode .modal-head button { pointer-events: auto; color: #fff; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head h3 span { margin-left: 8px; font-size: 12px; font-weight: 400; opacity: .72; }
.modal-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.modal-close { width: 30px; height: 30px; border: 0; background: transparent; font-size: 22px; color: #8b959e; }
.modal-body { overflow: auto; padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; }
.modal-field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.modal-field label { font-size: 12px; color: #68747f; }
.modal-field input { height: 40px; border: 1px solid #dce2e7; border-radius: 8px; padding: 0 11px; outline: none; }
.modal-field input:focus { border-color: var(--blue); }
.replace-dropzone { min-height: 210px; background: #f8fbfd; }
.continuation-prompt-list { display: flex; flex-direction: column; gap: 15px; }
.continuation-prompt-row { display: flex; flex-direction: column; gap: 7px; }
.continuation-prompt-row span { color: #53606b; font-size: 12px; font-weight: 600; }
.continuation-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: start; }
.continuation-input-row textarea { height: 84px; min-height: 70px; padding-bottom: 10px; }
.continuation-random { height: 34px; padding: 0 11px; border: 1px solid #b9dceb; border-radius: 7px; background: #f1faff; color: var(--blue-dark); font-size: 12px; }
.continuation-random:hover { border-color: var(--blue); background: #e8f7fd; }
.tip { background: #f2f9fd; color: #557484; padding: 10px 12px; border-radius: 8px; font-size: 12px; line-height: 1.6; }
.list-row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.list-row.clickable:hover { background: #f6fafc; cursor: pointer; }
.list-row .content { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .delete { border: 0; background: transparent; color: #a4adb5; }
.list-row .delete:hover { color: var(--danger); }
.add-row { display: flex; gap: 8px; margin-bottom: 12px; }
.add-row input { height: 38px; flex: 1; border: 1px solid #dce2e7; border-radius: 8px; padding: 0 10px; }
.preview-gallery { flex: 1; min-height: 0; display: grid; grid-template-columns: 96px minmax(0, 1fr); }
.preview-thumbnails { padding: 62px 10px 14px; overflow-y: auto; background: rgba(0,0,0,.3); display: flex; flex-direction: column; gap: 9px; }
.preview-thumb { flex: none; width: 76px; height: 76px; padding: 3px; border: 2px solid transparent; border-radius: 8px; background: rgba(255,255,255,.08); opacity: .62; }
.preview-thumb:hover { opacity: .9; }
.preview-thumb.active { border-color: var(--blue); opacity: 1; }
.preview-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: 4px; }
.preview-stage { min-width: 0; min-height: 0; display: grid; place-items: center; overflow: hidden; position: relative; }
.preview-stage > #previewImage { width: auto; height: auto; max-width: calc(100vw - 128px); max-height: calc(100vh - 32px); object-fit: contain; transform-origin: center; transition: transform .12s; cursor: grab; user-select: none; touch-action: none; }
.preview-stage img.dragging { cursor: grabbing; transition: none; }
.preview-nav { position: absolute; top: 50%; width: 46px; height: 64px; margin-top: -32px; border: 0; border-radius: 9px; background: rgba(0,0,0,.42); color: #fff; font-size: 38px; line-height: 1; z-index: 2; }
.preview-nav:hover { background: rgba(0,0,0,.65); }
.preview-nav:disabled { opacity: .18; cursor: default; }
.preview-nav.previous { left: 18px; }
.preview-nav.next { right: 18px; }
.zoom-tools { position: absolute; bottom: 20px; display: flex; align-items: center; gap: 7px; background: rgba(0,0,0,.58); padding: 7px; border-radius: 9px; color: #fff; }
.zoom-tools button { width: 34px; height: 30px; border: 0; border-radius: 6px; color: #fff; background: rgba(255,255,255,.14); }
.zoom-tools span { width: 54px; text-align: center; font-size: 12px; }
.toast-stack { position: fixed; z-index: 200; right: 22px; top: 82px; display: flex; flex-direction: column; gap: 8px; }
.global-drop-overlay { display: none; position: fixed; inset: 0; z-index: 300; place-items: center; background: rgba(21,159,224,.14); border: 3px dashed var(--blue); color: var(--blue-dark); font-size: 24px; font-weight: 700; pointer-events: none; }
body.dragging-files .global-drop-overlay { display: grid; }
.toast { background: #27333d; color: #fff; border-radius: 9px; padding: 11px 15px; box-shadow: var(--shadow); animation: toast-in .2s ease-out; max-width: 360px; }
.toast.error { background: #b93649; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@keyframes toast-in { from { transform: translateY(-7px); opacity: 0; } }
@media (min-width: 901px) {
  html, body { height: 100%; overflow: hidden; }
  .workspace { height: calc(100vh - 50px); min-height: 0; overflow: hidden; }
  .control-panel, .results-panel { height: 100%; min-height: 0; overscroll-behavior: contain; }
  .control-panel { position: static; max-height: none; overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; }
  .control-panel::-webkit-scrollbar { width: 0; height: 0; display: none; }
  .results-panel { overflow-y: auto; }
}
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; padding: 12px; }
  .control-panel { position: static; max-height: none; }
  .topbar { padding: 0 12px; gap: 10px; }
  .results-panel { min-height: 500px; }
  .fullscreen-text { display: none; }
}
@media (max-width: 560px) {
  .brand span:last-child { display: none; }
  .top-actions .button { padding: 0 9px; }
  .top-actions #bridgeStatusBtn { display: none; }
  .session-tab { min-width: 105px; }
  .result-header-actions { flex-direction: column; }
  .generation-head { align-items: flex-start; }
  .generation-head-right { align-items: flex-end; flex-direction: column; gap: 5px; }
  .format-cascade { grid-template-columns: .72fr .62fr 1.35fr; gap: 6px; }
  .format-cascade select { font-size: 12px; padding: 0 6px; }
  .continued-grid { grid-template-columns: 1fr 1fr; }
  .uploads { grid-template-columns: 1fr 1fr; }
}
.result-header-actions { display: flex; gap: 9px; }
