.cv-history-dialog {
  --ch-accent: var(--violet, #a78bfa);
  box-sizing: border-box;
  width: min(1820px, calc(100vw - 64px));
  max-width: none;
  height: calc(100dvh - 64px);
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 25px 100px #0006;
  font: inherit;
  font-size: 13px;
}
.cv-history-dialog[open] { display: flex; flex-direction: column; }
.cv-history-dialog::backdrop { background: #0009; backdrop-filter: blur(4px); }
.cv-history-dialog *, .cv-history-dialog *::before, .cv-history-dialog *::after { box-sizing: border-box; }
.cv-history-dialog [hidden] { display: none !important; }
.cv-history-dialog button, .cv-history-dialog select { font: inherit; }
.cv-history-dialog button { cursor: pointer; }
.cv-history-dialog button:disabled, .cv-history-dialog select:disabled { cursor: default; opacity: .45; }
.cv-history-dialog :is(button, select):focus-visible { outline: 2px solid var(--ch-accent); outline-offset: 3px; }
.cv-history-dialog svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.cv-history-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 28px 34px 22px; flex: 0 0 auto; }
.cv-history-header h2 { margin: 0 0 5px; font-size: 20px; font-weight: 700; line-height: 1.4; }
.cv-history-summary { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.cv-history-close { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--muted); }
.cv-history-close:hover { color: var(--text); background: var(--surface-raised); }
.cv-history-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 9px 34px 17px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.cv-history-tabs, .cv-history-actions { display: flex; align-items: center; gap: 10px; }
.cv-history-tabs { gap: 22px; align-self: stretch; }
.cv-history-tab { position: relative; display: flex; gap: 8px; align-items: center; padding: 12px 5px; border: 0; background: transparent; color: var(--muted); font-size: 14px !important; white-space: nowrap; }
.cv-history-tab[aria-selected="true"] { color: var(--text); font-weight: 700; }
.cv-history-tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; border-radius: 2px; background: var(--ch-accent); }
.cv-history-tab-count { font-size: 12px; font-weight: 400; }
.cv-history-tab[aria-selected="true"] .cv-history-tab-count { color: var(--ch-accent); }
.cv-history-button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--soft); white-space: nowrap; }
.cv-history-actions > .cv-history-button { height: 30px; min-height: 30px; gap: 6px; padding: 4px 9px; border-radius: 8px; font-size: 13px; line-height: 20px; }
.cv-history-actions > .cv-history-button > svg { width: 16px; height: 16px; }
.cv-history-actions > .cv-history-button[aria-label="刷新历史资产"] { width: 30px; min-width: 30px; padding-inline: 6px; }
.cv-history-button[aria-pressed="true"], .cv-history-button:hover:not(:disabled) { background: var(--surface-raised); color: var(--text); }
.cv-history-error { flex: 0 0 auto; margin: 0; padding: 10px 34px; color: var(--danger, #f58b9c); background: color-mix(in srgb, var(--danger, #f58b9c) 8%, transparent); border-bottom: 1px solid var(--line); }
.cv-history-body { display: grid; grid-template-columns: minmax(0, 7fr) minmax(250px, 3fr); min-height: 0; flex: 1 1 auto; overflow: hidden; }
.cv-history-grid { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 20px 32px 30px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.cv-history-date-group + .cv-history-date-group { margin-top: 27px; }
.cv-history-date { display: flex; align-items: center; gap: 16px; margin: 0 0 19px; color: var(--soft); font-size: 13px; font-weight: 650; letter-spacing: .04em; }
.cv-history-date-line { height: 1px; flex: 1; background: var(--line); opacity: .65; }
.cv-history-date-count { font-weight: 400; color: var(--muted); }
.cv-history-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.cv-history-card { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 1; padding: 0; overflow: hidden; border: 2px solid transparent; border-radius: 14px; background: var(--surface-raised); color: var(--muted); touch-action: manipulation; }
.cv-history-card > img, .cv-history-card > video { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.cv-history-card > svg { width: 30px; height: 30px; }
.cv-history-card:hover:not(:disabled), .cv-history-card:focus-visible, .cv-history-card.is-selected { border-color: var(--ch-accent); }
.cv-history-card-hint { position: absolute; left: 50%; bottom: 12px; display: flex; align-items: center; justify-content: center; gap: 6px; max-width: calc(100% - 14px); padding: 7px 11px; border: 1px solid #ffffff1f; border-radius: 999px; color: #fff; background: #171717b8; backdrop-filter: blur(8px); box-shadow: 0 2px 10px #0002; font-size: 12px; line-height: 1.3; white-space: nowrap; pointer-events: none; opacity: 0; visibility: hidden; transform: translate(-50%, 4px); transition: opacity .14s ease, transform .14s ease, visibility .14s; }
.cv-history-card-hint svg { width: 16px; height: 16px; }
.cv-history-card:focus-visible .cv-history-card-hint { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
@media (hover: hover) { .cv-history-card:hover .cv-history-card-hint { opacity: 1; visibility: visible; transform: translate(-50%, 0); } }
.cv-history-dialog:is(.is-batch, [aria-busy="true"]) .cv-history-card-hint { opacity: 0; visibility: hidden; transform: translate(-50%, 4px); }
.cv-history-play { position: absolute; top: 9px; right: 9px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #000b; color: #fff; }
.cv-history-play svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.cv-history-select { position: absolute; top: 10px; left: 10px; display: none; place-items: center; width: 23px; height: 23px; border: 1px solid #fff9; border-radius: 7px; background: #0008; color: transparent; }
.cv-history-select svg { width: 17px; height: 17px; stroke-width: 2.2; }
.is-batch .cv-history-select { display: grid; }
.cv-history-card.is-selected .cv-history-select { border-color: var(--ch-accent); background: var(--ch-accent); color: var(--bg); }
.cv-history-preview { min-height: 0; padding: 24px 25px; border-left: 1px solid var(--line); background: color-mix(in srgb, var(--surface-raised) 30%, var(--surface)); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.cv-history-preview-empty { display: grid; place-items: center; min-height: 100%; margin: 0; padding: 20px; color: var(--muted); text-align: center; }
.cv-history-preview-stage { display: grid; place-items: center; width: 100%; aspect-ratio: 1.15; overflow: hidden; border-radius: 16px; background: var(--surface-raised); }
.cv-history-preview-stage > img, .cv-history-preview-stage > video { display: block; width: 100%; height: 100%; max-height: 48dvh; object-fit: contain; }
.cv-history-preview-stage > video { background: #000; }
.cv-history-media-error { padding: 20px; text-align: center; color: var(--danger, #f58b9c); }
.cv-history-preview-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 18px 0; }
.cv-history-preview-meta strong { font-size: 13px; }
.cv-history-preview-meta time { color: var(--muted); font-size: 12px; }
.cv-history-preview-prompt { margin: 0; color: var(--soft); font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.cv-history-add { display: inline-flex; align-items: center; justify-content: center; min-height: 37px; border: 1px solid transparent; border-radius: 9px; padding: 7px 16px; background: var(--ch-accent); color: var(--bg); white-space: nowrap; }
.cv-history-preview-add { margin-top: 20px; }
.cv-history-preview-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.cv-history-delete { color: var(--danger, #f58b9c); }
.cv-history-hide-dialog { width: min(420px, calc(100vw - 40px)); padding: 24px; border: 1px solid var(--line); border-radius: 16px; color: var(--text); background: var(--surface); font: inherit; box-shadow: 0 18px 70px #0006; }
.cv-history-hide-dialog::backdrop { background: #0008; }
.cv-history-hide-dialog h3 { margin: 0 0 17px; font-size: 19px; }
.cv-history-hide-dialog p { color: var(--soft); margin: 0 0 24px; }
.cv-history-hide-actions { display: flex; justify-content: flex-end; gap: 10px; }
.cv-history-hide-dialog button:focus-visible { outline: 2px solid var(--violet); outline-offset: 3px; }
.cv-history-hide-dialog button:disabled { opacity: .5; cursor: default; }
.cv-history-footer { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; min-height: 70px; padding: 14px 34px; border-top: 1px solid var(--line); flex: 0 0 auto; }
.cv-history-page-info { color: var(--muted); font-size: 12px; white-space: nowrap; }
.cv-history-pages { display: flex; align-items: center; justify-content: center; gap: 5px; }
.cv-history-pages .cv-history-button, .cv-history-page-button { display: grid; place-items: center; min-width: 34px; height: 36px; min-height: 36px; padding: 5px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.cv-history-page-button[aria-current="page"] { background: var(--ch-accent); color: var(--bg); font-weight: 700; }
.cv-history-page-button:hover:not(:disabled):not([aria-current]) { background: var(--surface-raised); color: var(--text); }
.cv-history-ellipsis { padding: 0 4px; color: var(--muted); }
.cv-history-footer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 15px; }
.cv-history-size { display: flex; align-items: center; gap: 9px; color: var(--muted); white-space: nowrap; }
.cv-history-size select { min-height: 35px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 9px; color: var(--soft); background: var(--surface); }
.cv-history-skeleton, .cv-history-skeleton-date { border-radius: 13px; background: var(--surface-raised); }
.cv-history-skeleton { aspect-ratio: 1; }
.cv-history-skeleton-date { width: 140px; height: 16px; margin: 7px 0 25px; }
@media (max-width: 1200px) {
  .cv-history-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cv-history-grid { padding-inline: 23px; }
  .cv-history-preview { padding: 22px 19px; }
  .cv-history-footer { grid-template-columns: auto 1fr; }
  .cv-history-pages { order: 3; grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .cv-history-dialog { width: calc(100vw - 20px); height: calc(100dvh - 20px); border-radius: 15px; font-size: 12px; }
  .cv-history-header { padding: 17px 17px 10px; }
  .cv-history-header h2 { font-size: 20px; }
  .cv-history-toolbar { flex-wrap: wrap; gap: 7px; padding: 3px 17px 12px; }
  .cv-history-tabs { gap: 12px; }
  .cv-history-tab { font-size: 14px !important; }
  .cv-history-tab-count { font-size: 12px; }
  .cv-history-actions { margin-left: auto; gap: 6px; }
  .cv-history-button { padding: 6px 8px; min-height: 33px; }
  .cv-history-body { grid-template-columns: minmax(0, 3fr) minmax(135px, 2fr); }
  .cv-history-grid { padding: 16px 12px; }
  .cv-history-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cv-history-card { border-radius: 10px; }
  .cv-history-date { gap: 8px; margin-bottom: 13px; font-size: 12px; }
  .cv-history-preview { padding: 16px 10px; }
  .cv-history-preview-stage { border-radius: 10px; }
  .cv-history-preview-meta { flex-wrap: wrap; gap: 4px; margin: 12px 0; }
  .cv-history-preview-meta strong { font-size: 12px; }
  .cv-history-preview-meta time { font-size: 12px; }
  .cv-history-play { width: 23px; height: 23px; top: 5px; right: 5px; }
  .cv-history-footer { padding: 11px 15px; gap: 8px; grid-template-columns: 1fr; }
  .cv-history-page-info { text-align: center; }
  .cv-history-footer-actions { gap: 8px; justify-content: center; flex-wrap: wrap; grid-row: 2; min-width: 0; }
  .cv-history-size { gap: 5px; }
  .cv-history-pages { gap: 2px; grid-row: 3; }
  .cv-history-pages .cv-history-button, .cv-history-page-button { min-width: 29px; height: 32px; }
  .cv-history-error { padding-inline: 17px; }
}
@media (max-width: 420px) {
  .cv-history-body { grid-template-columns: minmax(0, 1fr) minmax(125px, .8fr); }
  .cv-history-cards { grid-template-columns: minmax(0, 1fr); }
  .cv-history-footer-actions .cv-history-size > span { display: none; }
}
@media (prefers-reduced-motion: reduce) { .cv-history-card-hint { transition: none; } }
