/* UniDoc mother-project AI task pane, adapted only for UniPic image actions. */
#ai-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 28px;
  z-index: 90;
  width: 400px;
  min-width: 300px;
  max-width: 99vw;
  display: flex;
  flex-direction: column;
  background: #f8fafd;
  border-left: 1px solid #dadce0;
  box-shadow: -8px 0 28px rgba(60, 64, 67, .12);
  border-radius: 20px 0 0 20px;
  overflow: hidden;
  font: 13.5px/1.6 "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #1b1c1e;
}

#ai-panel.hidden { display: none; }
#ai-panel.ai-floating { border-radius: 20px; border: 1px solid #dadce0; height: min(88vh, 900px); bottom: auto; }
#ai-panel.ai-full {
  left: 0 !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none;
  border-radius: 0;
  border-left: 0;
}
#ai-panel.ai-full .ai-resizer { display: none; }
#ai-panel.ai-full .ai-msgs,
#ai-panel.ai-full .ai-dock { max-width: 820px; margin-left: auto; margin-right: auto; width: 100%; }

#ai-panel .ai-resizer {
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 7px;
  cursor: ew-resize;
  z-index: 2;
}
#ai-panel .ai-resizer:hover { background: linear-gradient(90deg, var(--primary), transparent); opacity: .35; }
body.ai-resizing { cursor: grabbing !important; user-select: none !important; }

#ai-panel .ai-head {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 58px;
  padding: 0 10px 0 16px;
  background: transparent;
  cursor: grab;
  flex: none;
}
#ai-panel .ai-head:active { cursor: grabbing; }
#ai-panel .ai-title { flex: 1; display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 600; white-space: nowrap; }
#ai-panel .ai-logo,
#ai-panel .ai-hello-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}
#ai-panel .ai-logo { width: 26px; height: 26px; }
#ai-panel .ai-logo img,
#ai-panel .ai-hello-logo img { display: block; width: 100%; height: 100%; }
#ai-panel .ai-name { color: var(--primary); font-weight: 600; }
#ai-panel .ai-head button {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #6b6f76;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .12s, color .12s;
}
#ai-panel .ai-head button:hover { background: rgba(0,0,0,.06); color: #1b1c1e; }

#ai-panel .ai-cfg {
  flex: none;
  padding: 10px 14px;
  border-bottom: 1px solid #eef0f3;
  background: #fafbfc;
}
#ai-panel .ai-cfg.hidden { display: none; }
#ai-panel .ai-cfg label { display: block; margin-bottom: 6px; font-size: 12px; color: #6b7480; }
#ai-panel .ai-cfg input {
  width: 100%;
  height: 26px;
  margin-top: 2px;
  padding: 0 8px;
  border: 1px solid #c3c9d2;
  border-radius: 3px;
  font: inherit;
  box-sizing: border-box;
}
#ai-panel .ai-warn { color: #b06a00; font-size: 11px; margin: 4px 0 8px; }
#ai-panel .settings-status { margin: 6px 0 8px; }
#ai-panel .ai-save {
  height: 26px;
  padding: 0 12px;
  border: 1px solid var(--primary);
  border-radius: 3px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}

#ai-panel .ai-msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 18px 6px;
  background: #f8fafd;
}
#ai-panel .ai-hello {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 16px 24px;
  gap: 14px;
}
#ai-panel .ai-hello-logo { width: 46px; height: 46px; font-size: 22px; }
#ai-panel .ai-hello-h { font-size: 26px; font-weight: 600; color: #24262b; letter-spacing: .3px; }
#ai-panel .ai-hello-sub { max-width: 420px; font-size: 13px; color: #7a7f87; line-height: 1.7; }

#ai-panel .ai-msg { display: flex; gap: 9px; margin-bottom: 16px; }
#ai-panel .ai-avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
}
#ai-panel .ai-avatar img { display: block; width: 100%; height: 100%; }
#ai-panel .ai-user { flex-direction: row-reverse; }
#ai-panel .ai-user .ai-avatar { background: #d7d3ca; color: #4a4741; }
#ai-panel .ai-assistant .ai-avatar { border-radius: 7px; background: transparent; }
#ai-panel .ai-bubble {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13.5px;
  line-height: 1.65;
  position: relative;
}
#ai-panel .ai-user .ai-bubble { background: #e8ebf2; color: #1b1c1e; border-bottom-right-radius: 5px; }
#ai-panel .ai-assistant .ai-bubble { background: #fff; color: #1b1c1e; border: 1px solid #eceae4; border-bottom-left-radius: 5px; box-shadow: 0 1px 3px rgba(20,30,50,.04); }
#ai-panel .ai-response-body { white-space: pre-wrap; }
#ai-panel .ai-response-body p { margin: 0; }
#ai-panel .ai-msg.error .ai-bubble { border-color: #fecaca; background: #fff7f7; }
#ai-panel .ai-response-body { user-select: text; }
#ai-panel .ai-msg.has-copy { margin-bottom: 34px; }
#ai-panel .ai-thinking-line {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  margin-bottom: 7px;
  color: #8a8f97;
  font-size: 12px;
  font-style: italic;
  line-height: 20px;
}
#ai-panel .ai-thinking-line i { flex: none; font-size: 14px; color: var(--primary); }
#ai-panel .ai-thinking-line span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#ai-panel .ai-thinking-line.complete { color: #a0a5ad; }
#ai-panel .ai-thinking-line.complete i { color: #8a939f; }

#ai-panel .ai-clarification-options {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
  white-space: normal;
}
#ai-panel .ai-clarification-options button {
  min-height: 30px;
  padding: 5px 11px;
  border: 1px solid #dfe4e7;
  border-radius: 999px;
  background: #f8faf9;
  color: #4c555b;
  font: inherit;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
}
#ai-panel .ai-clarification-options button:hover {
  border-color: color-mix(in srgb, var(--primary) 42%, #dfe4e7);
  background: color-mix(in srgb, var(--primary) 7%, #fff);
  color: var(--primary);
}
#ai-panel .ai-clarification-options button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 38%, transparent);
  outline-offset: 1px;
}

#ai-panel .ai-copy-row {
  position: absolute;
  right: 0;
  top: calc(100% + 2px);
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity .12s ease, transform .12s ease;
}
#ai-panel .ai-bubble:hover .ai-copy-row,
#ai-panel .ai-copy-row:focus-within {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
#ai-panel .ai-copy-answer {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: #fff;
  color: #7a8391;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(20, 30, 50, .10);
}
#ai-panel .ai-copy-answer:hover { background: #eef2f7; color: var(--primary); }
#ai-panel .ai-copy-answer:focus-visible { outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 1px; }
#ai-panel .ai-copy-answer.is-copied { color: #178447; background: #edf8f1; }
#ai-panel .ai-copy-answer.is-copy-error { color: #c2413b; background: #fff0ef; }

@media (hover: none) {
  #ai-panel .ai-copy-row { opacity: 1; pointer-events: auto; transform: none; }
}

/* UniDoc-style rich AI answers: GFM Markdown + local KaTeX. */
#ai-panel .ai-md { white-space: normal; min-width: 0; }
#ai-panel .ai-md p { margin: 0 0 8px; }
#ai-panel .ai-md p:last-child { margin-bottom: 0; }
#ai-panel .ai-md h1,
#ai-panel .ai-md h2,
#ai-panel .ai-md h3,
#ai-panel .ai-md h4,
#ai-panel .ai-md h5,
#ai-panel .ai-md h6 { margin: 11px 0 6px; color: #24262b; line-height: 1.35; font-weight: 700; }
#ai-panel .ai-md h1 { font-size: 18px; }
#ai-panel .ai-md h2 { font-size: 16px; }
#ai-panel .ai-md h3,
#ai-panel .ai-md h4,
#ai-panel .ai-md h5,
#ai-panel .ai-md h6 { font-size: 14px; }
#ai-panel .ai-md ul,
#ai-panel .ai-md ol { margin: 0 0 9px; padding-left: 22px; }
#ai-panel .ai-md li { margin: 3px 0; }
#ai-panel .ai-md li > p { margin-bottom: 3px; }
#ai-panel .ai-md input[type="checkbox"] { accent-color: var(--primary); pointer-events: none; }
#ai-panel .ai-md a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
#ai-panel .ai-md img { display: block; max-width: 100%; max-height: 260px; margin: 8px 0; border-radius: 8px; object-fit: contain; }
#ai-panel .ai-md hr { border: 0; border-top: 1px solid #e2e5e9; margin: 12px 0; }
#ai-panel .ai-md pre {
  position: relative;
  overflow: auto;
  margin: 7px 0;
  padding: 34px 11px 10px;
  border-radius: 8px;
  background: #0f1115;
  color: #c8d0dc;
  font: 11.5px/1.55 Consolas, "Courier New", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}
#ai-panel .ai-md code { padding: 1px 4px; border-radius: 4px; background: #eef1f6; color: #334155; font: 12px/1.5 Consolas, "Courier New", monospace; }
#ai-panel .ai-md pre code { padding: 0; background: none; color: inherit; }
#ai-panel .ai-code-copy {
  position: absolute;
  z-index: 2;
  top: 6px;
  right: 7px;
  padding: 4px 8px;
  border: 1px solid #3b4350;
  border-radius: 6px;
  background: #252a33;
  color: #d7dde8;
  cursor: pointer;
  font: 11px/1.2 "Segoe UI", "Microsoft YaHei", sans-serif;
}
#ai-panel .ai-code-copy:hover { background: #303744; color: #fff; }
#ai-panel .ai-md table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 8px 0; }
#ai-panel .ai-md th,
#ai-panel .ai-md td { border: 1px solid #dfe3ea; padding: 5px 8px; font-size: 12px; text-align: left; white-space: nowrap; }
#ai-panel .ai-md th { background: #f3f5f7; font-weight: 700; }
#ai-panel .ai-md blockquote { margin: 7px 0; padding: 3px 11px; border-left: 3px solid #cdd4de; color: #6b7480; }
#ai-panel .ai-math { max-width: 100%; }
#ai-panel .ai-math-block,
#ai-panel .ai-md .katex-display { margin: 8px 0; overflow-x: auto; overflow-y: hidden; text-align: center; }
#ai-panel .ai-md .katex { font-size: 1.02em; }
#ai-panel .ai-math-error { color: #b42318; }

#ai-panel .ai-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0 16px 37px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eaf6ee;
  color: #1f6b3a;
  font-size: 12.5px;
}
#ai-panel .ai-card-ask { background: #fff7e8; color: #8a5a00; }
#ai-panel .ai-card-ask .ai-req {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e8a13b;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
#ai-panel .ai-card-main { min-width: 0; flex: 1; }
#ai-panel .ai-card-main > strong { display: block; margin-bottom: 4px; }
#ai-panel .ai-card ul { margin: 0; padding-left: 18px; }
#ai-panel .ai-actrow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#ai-panel .ai-mini {
  height: auto;
  min-height: 28px;
  padding: 5px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  background: #fff;
  color: #454c56;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.3;
}
#ai-panel .ai-mini:hover { border-color: var(--primary); color: var(--primary); }
#ai-panel .ai-mini-primary { background: var(--primary) !important; border-color: var(--primary) !important; color: #fff !important; }

#ai-panel .ai-dock {
  flex: none;
  padding: 6px 18px 16px;
  background: #f8fafd;
}
#ai-panel .ai-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 0 10px; }
#ai-panel .ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid #dadce0;
  border-radius: 20px;
  background: #fff;
  color: #4a4f57;
  font-size: 12.5px;
  cursor: pointer;
  transition: all .12s;
}
#ai-panel .ai-chip:hover { border-color: #cfd4dc; color: #1b1c1e; background: #fbfbfa; box-shadow: 0 2px 8px rgba(20,30,50,.06); }
#ai-panel .ai-attach-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 8px; }
#ai-panel .ai-attach-bar[hidden] { display: none; }
#ai-panel .ai-attach-bar .ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 3px 6px 3px 10px;
  border-radius: 20px;
  background: #f2f1ec;
  border: 1px solid #e6e4de;
  font-size: 11.5px;
  color: #3b4350;
  cursor: default;
}
#ai-panel .ai-chip-ic { flex: none; width: 18px; height: 18px; display: grid; place-items: center; position: relative; overflow: hidden; border-radius: 4px; }
#ai-panel .ai-chip-ic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#ai-panel .ai-chip-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ai-panel .ai-chip-meta { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #8a93a0; }
#ai-panel .ai-chip-x {
  flex: none;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #8a93a0;
  font-size: 10px;
  cursor: pointer;
  line-height: 1;
}
#ai-panel .ai-chip-x:hover { background: #e3e6ea; color: #d23f31; }

#ai-panel .ai-composer {
  margin: 0;
  background: #fff;
  border: 1px solid #e6e4de;
  border-radius: 22px;
  padding: 12px 14px 8px;
  box-shadow: 0 4px 18px rgba(20,30,50,.07);
  transition: border-color .15s, box-shadow .15s;
}
#ai-panel .ai-composer:focus-within { border-color: #b9c6ea; box-shadow: 0 4px 22px rgba(65,116,224,.15); }
#ai-panel .ai-input {
  width: 100%;
  min-height: 24px;
  max-height: 200px;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  resize: none;
  padding: 2px 4px 6px;
  color: #1b1c1e;
  box-sizing: border-box;
  line-height: 1.6;
}
#ai-panel .ai-input::placeholder { color: #9aa0a8; }
#ai-panel .ai-composer-tools { display: flex; align-items: center; gap: 6px; }
#ai-panel .ai-tools-spacer { flex: 1; }
#ai-panel .ai-clip,
#ai-panel .ai-shot {
  flex: none;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #6b6f76;
  font-size: 15px;
  cursor: pointer;
  transition: background .12s;
}
#ai-panel .ai-clip:hover,
#ai-panel .ai-shot:hover,
#ai-panel .ai-clip.active,
#ai-panel .ai-shot.active { background: rgba(0,0,0,.06); color: #1b1c1e; }
#ai-panel .ai-modes { display: inline-flex; gap: 0; background: #f2f1ec; border-radius: 16px; padding: 2px; }
#ai-panel .ai-modes label {
  padding: 5px 12px;
  border-radius: 14px;
  color: #6b6f76;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .12s;
}
#ai-panel .ai-modes input { position: absolute; opacity: 0; width: 0; height: 0; }
#ai-panel .ai-modes label:has(input:checked) { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 4px rgba(20,30,50,.12); }
#ai-panel .ai-send {
  flex: none;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background-color: var(--primary);
  color: #fff;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 19V5M5 12l7-7 7 7'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  transition: filter .12s, transform .12s;
}
#ai-panel .ai-send:hover { filter: brightness(1.08); transform: translateY(-1px); }
#ai-panel .ai-send.busy { background-image: none; position: relative; }
#ai-panel .ai-send.busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 12px; height: 12px; border-radius: 3px; background: #fff; }

@media (max-width: 640px) {
  #ai-panel { width: calc(100vw - 8px); min-width: 0; bottom: 0; }
  #ai-panel .ai-dock { padding-left: 10px; padding-right: 10px; }
  #ai-panel .ai-msgs { padding-left: 10px; padding-right: 10px; }
  #ai-panel .ai-chip-meta { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #ai-panel *, #ai-panel *::before, #ai-panel *::after { transition-duration: .01ms !important; }
}
