/* 启未创艺 · 统一历史记录框架样式 (Unified History Framework)
   完全支持深色模式 (dark)、浅色模式 (default/light) 与奶油色模式 (cream) */

:root {
  --uh-dialog-bg: rgba(255, 255, 255, 0.94);
  --uh-dialog-border: rgba(0, 113, 227, 0.18);
  --uh-dialog-shadow: 0 28px 80px rgba(15, 35, 60, 0.28), 0 4px 16px rgba(0, 113, 227, 0.08);
  --uh-backdrop-bg: rgba(15, 23, 42, 0.45);
  --uh-header-bg: rgba(255, 255, 255, 0.88);
  --uh-header-border: rgba(0, 0, 0, 0.08);
  --uh-sidebar-bg: rgba(248, 250, 252, 0.8);
  --uh-sidebar-border: rgba(0, 0, 0, 0.07);
  --uh-mobile-tabs-bg: #f8fafc;
  
  --uh-text-title: #0c1e33;
  --uh-text-body: #1d1d1f;
  --uh-text-secondary: #475569;
  --uh-text-muted: #94a3b8;
  --uh-accent: #0071e3;
  --uh-accent-soft: rgba(0, 113, 227, 0.09);
  --uh-accent-hover: #005bb5;
  
  --uh-tab-text: #334155;
  --uh-tab-hover-bg: rgba(0, 113, 227, 0.06);
  --uh-tab-hover-text: #0071e3;
  --uh-tab-active-bg: #ffffff;
  --uh-tab-active-text: #0071e3;
  --uh-tab-active-border: rgba(0, 113, 227, 0.25);
  --uh-tab-active-shadow: 0 3px 10px rgba(0, 113, 227, 0.08);
  --uh-tab-count-bg: rgba(0, 0, 0, 0.05);
  --uh-tab-count-text: #64748b;
  --uh-tab-count-active-bg: rgba(0, 113, 227, 0.12);
  --uh-tab-count-active-text: #0071e3;
  
  --uh-card-bg: #ffffff;
  --uh-card-border: rgba(0, 0, 0, 0.08);
  --uh-card-hover-border: rgba(0, 113, 227, 0.28);
  --uh-card-shadow: 0 4px 14px rgba(0, 0, 0, 0.03);
  --uh-card-tag-bg: #f1f5f9;
  --uh-card-tag-text: #475569;
  
  --uh-btn-bg: #ffffff;
  --uh-btn-border: rgba(0, 0, 0, 0.12);
  --uh-btn-text: #334155;
  --uh-btn-hover-bg: #f1f5f9;
  --uh-btn-hover-text: #0f172a;
  --uh-btn-primary-bg: rgba(0, 113, 227, 0.08);
  --uh-btn-primary-border: rgba(0, 113, 227, 0.25);
  --uh-btn-primary-text: #0071e3;
  --uh-btn-primary-hover-bg: #0071e3;
  --uh-btn-primary-hover-text: #ffffff;
  
  --uh-thumb-bg: #f8fafc;
  --uh-thumb-border: rgba(0, 0, 0, 0.06);
  --uh-thumb-placeholder-bg: rgba(0, 0, 0, 0.04);
  --uh-thumb-placeholder-text: #94a3b8;
  --uh-close-bg: rgba(0, 0, 0, 0.04);
  --uh-close-text: #475569;
  --uh-close-border: rgba(0, 0, 0, 0.08);
}

/* 深色模式深色匹配 */
:root[data-theme="dark"] {
  --uh-dialog-bg: rgba(13, 23, 38, 0.94);
  --uh-dialog-border: rgba(142, 190, 239, 0.22);
  --uh-dialog-shadow: 0 30px 90px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  --uh-backdrop-bg: rgba(3, 7, 18, 0.72);
  --uh-header-bg: rgba(17, 30, 48, 0.92);
  --uh-header-border: rgba(255, 255, 255, 0.1);
  --uh-sidebar-bg: rgba(10, 18, 30, 0.75);
  --uh-sidebar-border: rgba(255, 255, 255, 0.08);
  --uh-mobile-tabs-bg: rgba(14, 25, 42, 0.95);
  
  --uh-text-title: #f1f5f9;
  --uh-text-body: #e2e8f0;
  --uh-text-secondary: #cbd5e1;
  --uh-text-muted: #8b9bb4;
  --uh-accent: #38bdf8;
  --uh-accent-soft: rgba(56, 189, 248, 0.15);
  --uh-accent-hover: #7dd3fc;
  
  --uh-tab-text: #94a3b8;
  --uh-tab-hover-bg: rgba(255, 255, 255, 0.06);
  --uh-tab-hover-text: #f1f5f9;
  --uh-tab-active-bg: rgba(28, 48, 76, 0.9);
  --uh-tab-active-text: #38bdf8;
  --uh-tab-active-border: rgba(56, 189, 248, 0.45);
  --uh-tab-active-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  --uh-tab-count-bg: rgba(255, 255, 255, 0.08);
  --uh-tab-count-text: #94a3b8;
  --uh-tab-count-active-bg: rgba(56, 189, 248, 0.22);
  --uh-tab-count-active-text: #7dd3fc;
  
  --uh-card-bg: rgba(19, 33, 53, 0.78);
  --uh-card-border: rgba(255, 255, 255, 0.1);
  --uh-card-hover-border: rgba(56, 189, 248, 0.38);
  --uh-card-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --uh-card-tag-bg: rgba(255, 255, 255, 0.08);
  --uh-card-tag-text: #94a3b8;
  
  --uh-btn-bg: rgba(25, 42, 66, 0.85);
  --uh-btn-border: rgba(255, 255, 255, 0.14);
  --uh-btn-text: #e2e8f0;
  --uh-btn-hover-bg: rgba(38, 64, 98, 0.95);
  --uh-btn-hover-text: #ffffff;
  --uh-btn-primary-bg: rgba(56, 189, 248, 0.12);
  --uh-btn-primary-border: rgba(56, 189, 248, 0.35);
  --uh-btn-primary-text: #38bdf8;
  --uh-btn-primary-hover-bg: #38bdf8;
  --uh-btn-primary-hover-text: #041226;
  
  --uh-thumb-bg: rgba(10, 18, 30, 0.65);
  --uh-thumb-border: rgba(255, 255, 255, 0.1);
  --uh-thumb-placeholder-bg: rgba(255, 255, 255, 0.04);
  --uh-thumb-placeholder-text: #64748b;
  --uh-close-bg: rgba(255, 255, 255, 0.08);
  --uh-close-text: #cbd5e1;
  --uh-close-border: rgba(255, 255, 255, 0.12);
}

/* 奶油暖色主题适配 */
:root[data-theme="cream"] {
  --uh-dialog-bg: rgba(253, 250, 243, 0.96);
  --uh-dialog-border: rgba(197, 160, 89, 0.25);
  --uh-dialog-shadow: 0 28px 80px rgba(60, 45, 25, 0.18);
  --uh-backdrop-bg: rgba(35, 25, 15, 0.45);
  --uh-header-bg: rgba(250, 246, 237, 0.92);
  --uh-header-border: rgba(197, 160, 89, 0.15);
  --uh-sidebar-bg: rgba(246, 240, 228, 0.8);
  --uh-sidebar-border: rgba(197, 160, 89, 0.15);
  --uh-mobile-tabs-bg: #f8f3e8;
  
  --uh-text-title: #2d2416;
  --uh-text-body: #3c3222;
  --uh-text-secondary: #5c4e36;
  --uh-text-muted: #8c7b64;
  --uh-accent: #c5a059;
  --uh-accent-soft: rgba(197, 160, 89, 0.14);
  --uh-accent-hover: #b08d48;
  
  --uh-tab-text: #5c4e36;
  --uh-tab-hover-bg: rgba(197, 160, 89, 0.12);
  --uh-tab-hover-text: #2d2416;
  --uh-tab-active-bg: #ffffff;
  --uh-tab-active-text: #b08d48;
  --uh-tab-active-border: rgba(197, 160, 89, 0.4);
  --uh-tab-active-shadow: 0 3px 10px rgba(60, 45, 25, 0.06);
  --uh-tab-count-bg: rgba(60, 45, 25, 0.06);
  --uh-tab-count-text: #8c7b64;
  --uh-tab-count-active-bg: rgba(197, 160, 89, 0.2);
  --uh-tab-count-active-text: #2d2416;
  
  --uh-card-bg: #ffffff;
  --uh-card-border: rgba(197, 160, 89, 0.18);
  --uh-card-hover-border: rgba(197, 160, 89, 0.45);
  --uh-card-shadow: 0 4px 14px rgba(60, 45, 25, 0.04);
  --uh-card-tag-bg: rgba(197, 160, 89, 0.12);
  --uh-card-tag-text: #5c4e36;
  
  --uh-btn-bg: #ffffff;
  --uh-btn-border: rgba(197, 160, 89, 0.22);
  --uh-btn-text: #3c3222;
  --uh-btn-hover-bg: #f8f3e8;
  --uh-btn-hover-text: #2d2416;
  --uh-btn-primary-bg: rgba(197, 160, 89, 0.12);
  --uh-btn-primary-border: rgba(197, 160, 89, 0.35);
  --uh-btn-primary-text: #96742f;
  --uh-btn-primary-hover-bg: #c5a059;
  --uh-btn-primary-hover-text: #ffffff;
  
  --uh-thumb-bg: #faf6ed;
  --uh-thumb-border: rgba(197, 160, 89, 0.15);
  --uh-thumb-placeholder-bg: rgba(197, 160, 89, 0.06);
  --uh-thumb-placeholder-text: #8c7b64;
  --uh-close-bg: rgba(60, 45, 25, 0.06);
  --uh-close-text: #5c4e36;
  --uh-close-border: rgba(197, 160, 89, 0.18);
}

/* 弹窗主体容器 */
.unified-history-dialog {
  border: 1px solid var(--uh-dialog-border);
  border-radius: 20px;
  background: var(--uh-dialog-bg);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  color: var(--uh-text-body);
  box-shadow: var(--uh-dialog-shadow);
  width: min(1120px, 94vw);
  height: 86vh;
  max-height: 86vh;
  padding: 0;
  margin: auto;
  overflow: hidden;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  z-index: 99999;
}

.unified-history-dialog::backdrop {
  background: var(--uh-backdrop-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.unified-history-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* 顶部固定栏：标题、当前范围与操作，关键操作始终可见，绝不被挤出 */
.unified-history-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--uh-header-border);
  background: var(--uh-header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10;
}

.unified-history-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.unified-history-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--uh-text-title);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.unified-history-scope-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--uh-accent-soft);
  color: var(--uh-accent);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.unified-history-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.unified-history-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  font-size: 0.84rem;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid var(--uh-btn-border);
  background: var(--uh-btn-bg);
  color: var(--uh-btn-text);
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.unified-history-btn:hover {
  background: var(--uh-btn-hover-bg);
  color: var(--uh-btn-hover-text);
  border-color: var(--uh-accent);
}

.unified-history-btn.is-refreshing svg {
  animation: unified-history-spin 0.8s linear infinite;
}

@keyframes unified-history-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.unified-history-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--uh-close-border);
  background: var(--uh-close-bg);
  color: var(--uh-close-text);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.16s ease;
  padding: 0;
  line-height: 1;
}

.unified-history-close-btn:hover {
  background: rgba(239, 68, 68, 0.18);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
  transform: scale(1.06);
}

/* 顶部选择区：在视口窄或者大比例缩放时激活 */
.unified-history-mobile-tabs {
  display: none;
  flex-shrink: 0;
  padding: 8px 16px;
  background: var(--uh-mobile-tabs-bg);
  border-bottom: 1px solid var(--uh-header-border);
  gap: 8px;
  align-items: center;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.unified-history-mobile-select {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--uh-btn-border);
  background: var(--uh-btn-bg);
  color: var(--uh-text-title);
  font-size: 0.86rem;
  font-weight: 600;
  outline: none;
  width: 100%;
  max-width: 280px;
}

/* 主体分栏：左侧功能标签栏 + 右侧记录展示区 */
.unified-history-main {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

/* 左侧标签栏 */
.unified-history-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--uh-sidebar-bg);
  border-right: 1px solid var(--uh-sidebar-border);
  padding: 16px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.unified-history-tab-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--uh-tab-text);
  font-size: 0.88rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.16s ease;
  user-select: none;
}

.unified-history-tab-btn:hover {
  background: var(--uh-tab-hover-bg);
  color: var(--uh-tab-hover-text);
}

.unified-history-tab-btn.is-active {
  background: var(--uh-tab-active-bg);
  color: var(--uh-tab-active-text);
  font-weight: 650;
  border-color: var(--uh-tab-active-border);
  box-shadow: var(--uh-tab-active-shadow);
}

.unified-history-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: var(--uh-tab-count-bg);
  color: var(--uh-tab-count-text);
  min-width: 18px;
}

.unified-history-tab-btn.is-active .unified-history-tab-count {
  background: var(--uh-tab-count-active-bg);
  color: var(--uh-tab-count-active-text);
}

/* 侧边栏底部同步说明 */
.unified-history-sync-note {
  margin-top: auto;
  padding: 12px 8px 4px;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--uh-text-muted);
  border-top: 1px dashed var(--uh-header-border);
}

/* 右侧内容展示区 */
.unified-history-content {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  padding: 20px 24px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* 加载中状态 */
.unified-history-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--uh-text-muted);
  gap: 14px;
  flex: 1;
}

.unified-history-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0, 113, 227, 0.18);
  border-top-color: var(--uh-accent);
  border-radius: 50%;
  animation: unified-history-spin 0.8s linear infinite;
}

/* 错误与重试 */
.unified-history-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 14px;
  flex: 1;
}

.unified-history-error-msg {
  color: #ef4444;
  font-size: 0.94rem;
  font-weight: 500;
  margin: 0;
}

.unified-history-retry-btn {
  padding: 7px 18px;
  background: var(--uh-accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.16s ease;
}

.unified-history-retry-btn:hover {
  background: var(--uh-accent-hover);
}

/* 空状态 */
.unified-history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--uh-text-muted);
  font-size: 0.92rem;
  flex: 1;
}

/* 记录列表与组卡片 */
.unified-history-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.unified-history-group-card {
  border: 1px solid var(--uh-card-border);
  border-radius: 14px;
  background: var(--uh-card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 16px;
  box-shadow: var(--uh-card-shadow);
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
}

.unified-history-group-card:hover {
  border-color: var(--uh-card-hover-border);
}

.unified-history-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.unified-history-group-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.unified-history-group-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 650;
  color: var(--uh-text-title);
}

.unified-history-group-tag {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 500;
  background: var(--uh-card-tag-bg);
  color: var(--uh-card-tag-text);
}

.unified-history-group-time {
  font-size: 0.78rem;
  color: var(--uh-text-muted);
}

.unified-history-group-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.unified-history-action-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--uh-btn-border);
  background: var(--uh-btn-bg);
  color: var(--uh-btn-text);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.16s ease;
}

.unified-history-action-btn:hover {
  background: var(--uh-btn-hover-bg);
  color: var(--uh-btn-hover-text);
  border-color: var(--uh-accent);
}

.unified-history-action-btn.is-primary {
  background: var(--uh-btn-primary-bg);
  border-color: var(--uh-btn-primary-border);
  color: var(--uh-btn-primary-text);
}

.unified-history-action-btn.is-primary:hover {
  background: var(--uh-btn-primary-hover-bg);
  color: var(--uh-btn-primary-hover-text);
}

/* 组内图片网格：自适应多列 */
.unified-history-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 12px;
}

.unified-history-thumb-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--uh-thumb-bg);
  border: 1px solid var(--uh-thumb-border);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.unified-history-thumb-item:hover {
  transform: translateY(-2px);
  border-color: var(--uh-accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.unified-history-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 优雅的破图与占位状态 */
.unified-history-thumb-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 10px;
  box-sizing: border-box;
  text-align: center;
  background: var(--uh-thumb-placeholder-bg);
  color: var(--uh-thumb-placeholder-text);
  font-size: 0.72rem;
  line-height: 1.35;
  user-select: none;
}

.unified-history-thumb-placeholder svg {
  width: 24px;
  height: 24px;
  margin-bottom: 6px;
  opacity: 0.6;
}

.unified-history-thumb-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  font-size: 0.68rem;
  background: rgba(0, 0, 0, 0.68);
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.unified-history-thumb-zoom-icon {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.16s ease;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.unified-history-thumb-item:hover .unified-history-thumb-zoom-icon {
  opacity: 1;
}

/* 缩放响应式规则 (保证 80%, 100%, 125%, 150%, 200% 时关键操作不被挤出) */
@media (max-width: 768px), (max-height: 580px) {
  .unified-history-dialog {
    width: 96vw;
    height: 94vh;
    max-height: 94vh;
    border-radius: 14px;
  }
  .unified-history-sidebar {
    display: none !important;
  }
  .unified-history-mobile-tabs {
    display: flex !important;
  }
  .unified-history-header {
    padding: 10px 14px;
  }
  .unified-history-title {
    font-size: 1rem;
  }
  .unified-history-content {
    padding: 14px;
  }
  .unified-history-group-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
  }
}
