#agent-image-history[hidden], .agent-history-reopen[hidden], .agent-history-divider[hidden] { display: none !important; }
#agent-image-history {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background: #f9fafb;
  color: #202124;
  overflow: hidden;
}
.agent-history-head { display: flex; align-items: center; justify-content: flex-end; padding: 10px 18px 0; }
.agent-history-icon { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; padding: 10px; border: 0; border-radius: 50%; background: transparent; color: #70757b; font: inherit; font-size: 28px; cursor: pointer; }
.agent-history-icon svg { width: 20px; height: 20px; }
.agent-history-icon:hover:not(:disabled) { background: #eceef0; color: #202124; }
.agent-history-icon:disabled { opacity: .25; cursor: default; }
.agent-history-icon[data-history-close] { background: #202124; color: #fff; }
.agent-history-icon[data-history-close]:hover { background: #45484d; color: #fff; }
.agent-history-reopen { position: fixed; right: 12px; top: 50%; transform: translateY(-50%); z-index: 40; display: grid; place-items: center; width: 44px; height: 56px; padding: 10px; border: 1px solid #e0e3e7; border-radius: 14px; background: #fff; color: #202124; box-shadow: 0 4px 16px #16203312; cursor: pointer; transition: background .18s, border-color .18s; }
.agent-history-reopen svg { width: 20px; height: 20px; }
.agent-history-reopen:hover { background: #f1f3f5; border-color: #afb5bd; }
.agent-history-reopen:focus-visible { outline: 2px solid #778ba9; outline-offset: 3px; }
.agent-history-stage { display: grid; place-items: center; min-height: 0; min-width: 0; padding: 12px 28px; position: relative; }
.agent-history-original { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; cursor: grab; filter: drop-shadow(0 10px 18px #1c26330d); }
.agent-history-original:active { cursor: grabbing; }
.agent-history-details { padding: 12px 28px 6px; }
.agent-history-position { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; color: #96999e; font-size: 11px; }
.agent-history-position > :first-child { color: #676d75; font-variant-numeric: tabular-nums; }
.agent-history-actions { display: flex; flex-direction: row; justify-content: center; flex-wrap: wrap; gap: 8px; }
.agent-history-action { display: inline-flex; justify-content: center; align-items: center; min-height: 44px; padding: 8px 15px; border: 1px solid #d7dadd; border-radius: 999px; background: #fff; color: #33383f; font: inherit; font-size: 12px; cursor: pointer; transition: background .15s, border-color .15s; }
.agent-history-action.is-save { background: #202124; border-color: #202124; color: #fff; order: 10; }
.agent-history-action:hover:not(:disabled) { border-color: #8c9299; background: #eef0f3; }
.agent-history-action.is-save:hover:not(:disabled) { background: #45484d; }
.agent-history-action:disabled { opacity: .5; cursor: default; }
.agent-history-footer { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 10px 18px 22px; border-top: 1px solid #eceef0; }
.agent-history-strip { display: flex; gap: 9px; padding: 6px 3px; min-width: 0; flex: 1; overflow-x: auto; scrollbar-width: thin; overscroll-behavior: contain; }
.agent-history-strip button { position: relative; flex: 0 0 68px; width: 68px; aspect-ratio: 1; border: 2px solid transparent; padding: 3px; border-radius: 12px; background: #fff; cursor: pointer; }
.agent-history-strip button img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: 7px; cursor: grab; }
.agent-history-strip button span { position: absolute; bottom: 5px; right: 5px; padding: 1px 4px; border-radius: 4px; background: #0009; color: white; font-size: 9px; }
.agent-history-strip button.is-selected { border-color: #262a31; }
.agent-history-strip button:hover { background: #e9ecf0; }
#agent-image-history button:focus-visible { outline: 2px solid #778ba9; outline-offset: 3px; }
.agent-history-error { display: none; text-align: center; color: #7c8087; font-size: 13px; }
.agent-history-error button { display: block; margin: 12px auto; padding: 10px 16px; border: 1px solid #ddd; background: white; border-radius: 10px; cursor: pointer; }
#agent-image-history.has-image-error .agent-history-original { display: none; }
#agent-image-history.has-image-error .agent-history-error { display: block; }
#agent-chat-composer.is-history-dragging .agent-inspire-card { outline: 2px dashed #a5afbd; outline-offset: 5px; }
#agent-chat-composer.is-history-over .agent-inspire-card { outline-color: #536b8a; background: #f1f5fa !important; }
.agent-history-divider { grid-column: 2; grid-row: 1; position: relative; cursor: col-resize; touch-action: none; background: #f9fafb; z-index: 2; }
.agent-history-divider::before { content: ''; position: absolute; inset: 0 auto; left: 3px; width: 1px; background: #e0e3e7; }
.agent-history-divider::after { content: ''; position: absolute; left: 2px; top: calc(50% - 20px); width: 3px; height: 40px; border-radius: 3px; background: #a1a8b2; }
.agent-history-divider:hover::after, .agent-history-divider:focus-visible::after { background: #536b8a; }
.agent-history-divider:focus-visible { outline: 2px solid #536b8a; outline-offset: -2px; }
body.agent-history-resizing, body.agent-history-resizing * { cursor: col-resize !important; user-select: none !important; }
@media (min-width: 961px) and (hover: hover) and (pointer: fine) {
  body.agent-bifang-host.agent-history-open #agent-layout.agent-layout { display: grid !important; grid-template-columns: minmax(0, calc((100% - 8px) * var(--agent-history-chat-ratio, .5))) 8px minmax(0, 1fr) !important; gap: 0; }
  body.agent-bifang-host.agent-history-open .agent-chat-panel { grid-column: 1 !important; grid-row: 1; --agent-chat-col: calc(100% - 48px); min-width: 0; width: 100% !important; padding: 0 0 14px !important; overflow: hidden !important; }
  body.agent-history-open #agent-image-history { grid-column: 3; grid-row: 1; }
  body.agent-history-open #agent-thread .bifang-agent-image-actions { display: none; }
  body.agent-history-open #agent-thread .bifang-agent-result-card { grid-template-columns: minmax(0, 1fr); padding: 14px; border: 1px solid #e0e3e7; border-radius: 16px; background: #f9fafb; }
  body.agent-bifang-host #agent-thread .bifang-agent-result-card > .agent-result-image { width: auto; height: auto; max-width: min(100%, 480px); max-height: min(42vh, 360px); object-fit: contain; justify-self: center; }
  body.agent-bifang-host.agent-history-open .agent-chat-body { width: var(--agent-chat-col) !important; max-width: var(--agent-chat-col) !important; margin-inline: auto !important; }
  body.agent-bifang-host.agent-history-open #agent-chat-composer { width: var(--agent-chat-col) !important; max-width: var(--agent-chat-col) !important; margin-inline: auto !important; }
  body.agent-bifang-host.agent-history-open #agent-thread { width: 100% !important; padding-inline: 0 !important; }
  body.agent-bifang-host.agent-history-open .agent-inspire-card { width: 100% !important; max-width: none !important; }
  body.agent-history-open #agent-image-history { animation: agent-history-enter .25s ease-out; }
}
@media (max-width: 960px), (hover: none) and (pointer: coarse) {
  #agent-image-history, .agent-history-reopen, .agent-history-divider { display: none !important; }
}
@keyframes agent-history-enter { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  body.agent-history-open #agent-image-history { animation: none; }
  .agent-history-action, .agent-history-reopen { transition: none; }
}
