/* Knowledge Base Workbench (Cherry Markdown + OSS + RAG Playground) & Enterprise WeChat AI Customer Service styles. */

.kb-shell,
.wc-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 32px;
}

.kb-topbar,
.wc-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.kb-topbar-left,
.kb-topbar-right,
.wc-topbar-left,
.wc-topbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.kb-title-block h2,
.wc-title-block h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.kb-title-block p,
.wc-title-block p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.kb-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.kb-pill-oss { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.kb-pill-local { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.kb-pill-global { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.kb-pill-project { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.kb-pill-ok { background: #dcfce7; color: #15803d; border-color: #86efac; }
.kb-pill-warn { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.kb-pill-err { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }

/* Sub-tab switcher */
.kb-seg {
  display: inline-flex;
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}

.kb-seg button {
  border: 0;
  background: transparent;
  padding: 5px 13px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.kb-seg button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

/* KB Selector strip */
.kb-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.kb-card-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.kb-card-tab:hover { border-color: #93c5fd; background: #f8fbff; }
.kb-card-tab.is-active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-ink);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.kb-card-tab small {
  font-weight: 500;
  color: var(--muted);
  font-size: 11.5px;
}

/* Main 2-column / 3-column workbench */
.kb-grid {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.kb-grid.has-qa {
  grid-template-columns: 280px minmax(0, 1fr) 370px;
}

@media (max-width: 1240px) {
  .kb-grid.has-qa { grid-template-columns: 270px minmax(0, 1fr); }
  .kb-grid.has-qa .kb-qa-panel { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
  .kb-grid,
  .kb-grid.has-qa { grid-template-columns: 1fr; }
}

.kb-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.035);
}

.kb-sidebar-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fafcff;
}

.kb-sidebar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kb-search-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
}

.kb-dropzone {
  margin: 10px 12px 4px;
  padding: 11px 10px;
  border: 1.5px dashed #cbd5e1;
  border-radius: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  background: #f8fafc;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.kb-dropzone:hover,
.kb-dropzone.is-dragover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.kb-doc-list {
  max-height: 640px;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kb-cat-label {
  padding: 8px 8px 3px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.kb-doc-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.12s, border-color 0.12s;
}

.kb-doc-item:hover { background: #f8fafc; border-color: var(--line); }
.kb-doc-item.is-active { background: #eff6ff; border-color: #93c5fd; }

.kb-doc-item-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-doc-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
}

/* Editor / Viewer Stage */
.kb-stage-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fafcff;
}

.kb-stage-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 220px;
}

.kb-title-input {
  flex: 1;
  min-width: 180px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  background: #fff;
}

.kb-cat-input {
  width: 130px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
}

.kb-stage-meta {
  padding: 8px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.kb-cherry-host {
  min-height: 580px;
  height: clamp(580px, calc(100vh - 290px), 880px);
  width: 100%;
  position: relative;
}

.kb-cherry-host .cherry {
  box-shadow: none !important;
  border: 0 !important;
  height: 100% !important;
}

.kb-fallback-editor {
  width: 100%;
  min-height: 520px;
  border: 0;
  padding: 16px;
  font: 13.5px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace;
  resize: vertical;
}

.kb-file-preview-wrap {
  min-height: 540px;
  padding: 14px;
  background: #f8fafc;
}

.kb-chunks-list {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 600px;
  overflow-y: auto;
}

.kb-chunk-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  background: #fcfdff;
}

.kb-chunk-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.kb-chunk-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.65;
  color: #1e293b;
}

/* AI QA Playground */
.kb-qa-panel {
  display: flex;
  flex-direction: column;
  max-height: 760px;
}

.kb-qa-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kb-qa-head h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
}

.kb-qa-scope {
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.kb-qa-scope label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  background: #fff;
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 999px;
}

.kb-qa-messages {
  flex: 1;
  min-height: 280px;
  max-height: 460px;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f9fbfe;
}

.kb-msg {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13.2px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.kb-msg-user {
  align-self: flex-end;
  max-width: 88%;
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.kb-msg-ai {
  align-self: stretch;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 3px;
}

.kb-msg-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 11.5px;
  color: var(--muted);
}

.kb-cites {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kb-cite-btn {
  text-align: left;
  border: 1px solid #dbeafe;
  background: #f8fbff;
  border-radius: 8px;
  padding: 6px 9px;
  cursor: pointer;
  font-size: 12px;
  color: #1e293b;
}

.kb-cite-btn:hover { background: #eff6ff; border-color: #93c5fd; }

.kb-cite-title {
  font-weight: 600;
  color: var(--brand-ink);
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.kb-cite-snip {
  margin-top: 2px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kb-qa-form {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kb-qa-form textarea {
  width: 100%;
  min-height: 62px;
  max-height: 140px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  font-size: 13px;
}

.kb-qa-form-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* Enterprise WeChat AI CS Center */
.wc-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.wc-kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 15px;
}

.wc-kpi-label { font-size: 12px; color: var(--muted); }
.wc-kpi-val { font-size: 23px; font-weight: 800; color: var(--ink); margin-top: 4px; letter-spacing: -0.02em; }
.wc-kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.wc-channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 14px;
}

.wc-channel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wc-channel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.wc-channel-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.wc-kv {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 6px 10px;
  font-size: 12.5px;
  align-items: center;
}

.wc-kv dt { color: var(--muted); margin: 0; }
.wc-kv dd { margin: 0; color: var(--ink); word-break: break-all; }

.wc-code-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 8px;
  font: 12px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.wc-code-box span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.wc-guide-box {
  background: #f8fbff;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 13px;
  line-height: 1.7;
  color: #1e293b;
}

.wc-guide-box h4 { margin: 0 0 8px; font-size: 14px; color: #1e40af; }
.wc-guide-box ol { margin: 0; padding-left: 20px; }

.wc-sim-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
}

@media (max-width: 900px) {
  .wc-sim-grid { grid-template-columns: 1fr; }
}

.wc-table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-x: auto;
}

.wc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.wc-table th,
.wc-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.wc-table th {
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.wc-kb-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  max-height: 140px;
  overflow-y: auto;
}

.wc-kb-checklist label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
}

.kb-empty-stage {
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
}

.kb-empty-stage h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--ink);
}

/* ===== AI Image Studio 2.0 (LobeChat / ImgX / Cherry Studio Inspired) ===== */
.ais-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 36px;
}

.ais-studio {
  display: grid;
  grid-template-columns: 356px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 1120px) {
  .ais-studio {
    grid-template-columns: 316px minmax(0, 1fr);
  }
}

@media (max-width: 920px) {
  .ais-studio {
    grid-template-columns: 1fr;
  }
}

.ais-sidebar {
  position: sticky;
  top: 108px;
  max-height: calc(100vh - 124px);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (max-width: 920px) {
  .ais-sidebar {
    position: static;
    max-height: none;
  }
}

.ais-sec {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ais-sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 650;
  color: #334155;
}

.ais-sec-head small {
  font-weight: 500;
  color: var(--muted);
  font-size: 11.5px;
}

.ais-seg {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}

.ais-seg.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.ais-seg.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ais-seg button {
  border: 0;
  border-radius: 7px;
  background: transparent;
  padding: 6px 8px;
  font-size: 12.5px;
  font-weight: 550;
  color: #64748b;
  cursor: pointer;
  transition: background-color 0.14s, color 0.14s, box-shadow 0.14s;
  white-space: nowrap;
}

.ais-seg button:hover {
  color: #0f172a;
}

.ais-seg button.is-active {
  background: #ffffff;
  color: #1d4ed8;
  font-weight: 650;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(15, 23, 42, 0.04);
}

/* Aspect Ratio Visual Cards */
.ais-ratio-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ais-ratio-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px 8px;
  border-radius: 10px;
  border: 1px solid #dbe3ee;
  background: #f8fafc;
  cursor: pointer;
  color: #334155;
  transition: border-color 0.14s, background-color 0.14s, box-shadow 0.14s;
}

.ais-ratio-btn:hover {
  border-color: #93c5fd;
  background: #ffffff;
}

.ais-ratio-btn.is-active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.ais-ratio-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
}

.ais-ratio-frame {
  border: 2px solid currentColor;
  border-radius: 3px;
  background: rgba(37, 99, 235, 0.08);
}

.ais-ratio-frame.r-1-1 { width: 20px; height: 20px; }
.ais-ratio-frame.r-3-2 { width: 26px; height: 17px; }
.ais-ratio-frame.r-2-3 { width: 17px; height: 26px; }

.ais-ratio-btn strong { font-size: 12.5px; line-height: 1.2; }
.ais-ratio-btn small { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ais-ratio-btn.is-active small { color: #2563eb; }

/* Style Presets Grid */
.ais-style-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.ais-style-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  font-size: 12.5px;
  font-weight: 550;
  color: #334155;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.14s, background-color 0.14s, color 0.14s;
}

.ais-style-btn:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.ais-style-btn.is-active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 650;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.14);
}

.ais-style-cat {
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 5px;
  background: #f1f5f9;
  color: #64748b;
  font-weight: 500;
  flex-shrink: 0;
}

.ais-style-btn.is-active .ais-style-cat {
  background: #dbeafe;
  color: #1d4ed8;
}

/* Reference Image Upload & Strip */
.ais-ref-zone {
  border: 1.5px dashed #cbd5e1;
  border-radius: 10px;
  padding: 10px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s, background-color 0.15s;
}

.ais-ref-zone.is-drag {
  border-color: #2563eb;
  background: #eff6ff;
}

.ais-ref-drop-btn {
  border: 0;
  background: transparent;
  padding: 4px;
  text-align: center;
  color: #475569;
  font-size: 12px;
  cursor: pointer;
  line-height: 1.5;
}

.ais-ref-drop-btn strong {
  color: #1d4ed8;
}

.ais-ref-thumbs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.ais-ref-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  background: #fff;
}

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

.ais-ref-del {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ais-ref-del:hover {
  background: #dc2626;
}

.ais-advanced {
  border-top: 1px solid #edf2f7;
  padding-top: 10px;
}

.ais-advanced summary {
  font-size: 12.5px;
  font-weight: 650;
  color: #334155;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ais-advanced summary::-webkit-details-marker { display: none; }
.ais-advanced summary::after { content: "▾"; color: #94a3b8; font-size: 12px; }
.ais-advanced[open] summary::after { content: "▴"; }

.ais-advanced-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.ais-mini-param-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Right Main Workspace */
.ais-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.ais-composer {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.ais-composer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.ais-composer-head strong {
  font-size: 14px;
  color: #0f172a;
}

.ais-prompt-box {
  width: 100%;
  min-height: 98px;
  max-height: 240px;
  padding: 11px 13px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fcfdff;
  font-size: 13.8px;
  line-height: 1.62;
  color: #0f172a;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.ais-prompt-box:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.11);
}

.ais-composer-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.ais-enhance-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ais-enhance-group select {
  height: 32px;
  padding: 0 9px;
  font-size: 12px;
  border-color: #ddd6fe;
  background: #faf5ff;
  color: #5b21b6;
}

.ais-enhance-notes {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  font-size: 12px;
  color: #5b21b6;
}

.ais-chips-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.ais-chip-label {
  font-size: 11.5px;
  font-weight: 600;
  color: #64748b;
  margin-right: 2px;
}

.ais-mod-chip {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #334155;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  cursor: pointer;
  transition: border-color 0.13s, background-color 0.13s, color 0.13s;
}

.ais-mod-chip:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

.ais-tpl-chip {
  border: 1px solid #dbeafe;
  background: #f8fbff;
  color: #1e40af;
  border-radius: 8px;
  padding: 3.5px 10px;
  font-size: 11.5px;
  font-weight: 550;
  cursor: pointer;
  transition: border-color 0.13s, background-color 0.13s;
}

.ais-tpl-chip:hover {
  border-color: #60a5fa;
  background: #eff6ff;
}

.ais-composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid #eef2f7;
}

.ais-summary-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.ais-submit-btn {
  height: 38px;
  padding: 0 20px;
  font-size: 13.5px;
  font-weight: 650;
}

/* Live Async Queue Panel */
.ais-queue-panel {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-color: #bfdbfe;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.ais-queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ais-queue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.ais-job-card {
  border: 1px solid #dbe3ee;
  border-radius: 11px;
  background: #ffffff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ais-job-card.is-failed {
  border-color: #fecaca;
  background: #fffafb;
}

.ais-job-visual {
  position: relative;
  height: 148px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  background: linear-gradient(120deg, #eff6ff 0%, #f5f3ff 50%, #eff6ff 100%);
  background-size: 200% 200%;
  animation: aisShimmer 2.4s ease-in-out infinite;
  text-align: center;
}

.ais-job-card.is-failed .ais-job-visual {
  animation: none;
  background: #fef2f2;
}

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

.ais-job-spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid rgba(37, 99, 235, 0.18);
  border-top-color: #2563eb;
  animation: aisSpin 0.85s linear infinite;
}

@keyframes aisSpin {
  to { transform: rotate(360deg); }
}

.ais-job-bar {
  width: 82%;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.25);
  overflow: hidden;
}

.ais-job-bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  transition: width 0.35s ease;
}

.ais-job-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Gallery Header & Responsive Cards */
.ais-gallery-bar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fafcff;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.ais-gallery-search {
  width: clamp(200px, 22vw, 300px);
  height: 32px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: 8px;
}

.ais-gallery-bar select {
  height: 32px;
  padding: 0 9px;
  font-size: 12.5px;
  max-width: 190px;
}

.ais-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(256px, 1fr));
  gap: 14px;
}

.ais-grid.density-lg {
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

.ais-grid.density-sm {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 11px;
}

.ais-card {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.ais-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 8px 22px -10px rgba(15, 23, 42, 0.14);
  transform: translateY(-1px);
}

.ais-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background:
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1f5f9 75%),
    linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #ffffff;
}

.ais-thumb-btn {
  border: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  cursor: pointer;
  display: block;
}

.ais-thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}

.ais-card:hover .ais-thumb-btn img {
  transform: scale(1.02);
}

.ais-thumb-badges {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 5px;
  pointer-events: none;
}

.ais-float-badge {
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.68);
  color: #f8fafc;
  font-size: 10.5px;
  font-weight: 600;
  backdrop-filter: blur(6px);
}

.ais-float-badge.is-i2i {
  background: rgba(109, 40, 217, 0.82);
}

.ais-fav-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.56);
  color: #e2e8f0;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  transition: background-color 0.14s, color 0.14s, transform 0.14s;
}

.ais-fav-btn:hover {
  background: rgba(15, 23, 42, 0.8);
  transform: scale(1.06);
}

.ais-fav-btn.is-fav {
  background: #f59e0b;
  color: #ffffff;
}

.ais-thumb-overlay {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 6px;
  justify-content: center;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.ais-card:hover .ais-thumb-overlay,
.ais-card:focus-within .ais-thumb-overlay {
  opacity: 1;
  transform: translateY(0);
}

.ais-ov-btn {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(15, 23, 42, 0.78);
  color: #f8fafc;
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 550;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.ais-ov-btn:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.ais-card-body {
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.ais-card-prompt {
  font-size: 12.6px;
  color: var(--ink);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 37px;
}

.ais-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
}

.ais-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid #eef2f7;
}

/* Pro Split Lightbox */
.ais-lightbox-split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) 340px;
  gap: 18px;
  align-items: start;
}

@media (max-width: 860px) {
  .ais-lightbox-split {
    grid-template-columns: 1fr;
  }
}

.ais-lb-stage {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #dbe3ee;
  background:
    linear-gradient(45deg, #1e293b 25%, transparent 25%),
    linear-gradient(-45deg, #1e293b 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1e293b 75%),
    linear-gradient(-45deg, transparent 75%, #1e293b 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 380px;
}

.ais-lb-stage img {
  max-width: 100%;
  max-height: 68vh;
  object-fit: contain;
  display: block;
}

.ais-lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ais-lb-nav:hover { background: #2563eb; }
.ais-lb-nav.prev { left: 10px; }
.ais-lb-nav.next { right: 10px; }

.ais-lb-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 68vh;
  overflow-y: auto;
}

.ais-lb-block {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
}

.ais-lb-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 650;
  color: #64748b;
  margin-bottom: 6px;
}

.ais-lb-prompt-text {
  font-size: 12.8px;
  line-height: 1.62;
  color: #0f172a;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.ais-lb-specs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ais-lb-spec {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 9px;
}

.ais-lb-spec span {
  display: block;
  font-size: 11px;
  color: #64748b;
}

.ais-lb-spec strong {
  display: block;
  font-size: 12.5px;
  color: #0f172a;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.ai-img-modal-preview img {
  width: 100%;
  max-height: 440px;
  object-fit: contain;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #f8fafc;
  display: block;
}

dialog.ais-wide-dialog {
  width: min(1100px, 95vw);
}
