.history-page{
  padding: 26px 18px 40px;
  max-width: 1200px;
  margin: 0 auto;
}

.history-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  margin-bottom: 14px;
}
.history-title{
  margin:0;
  font-size: 26px;
  font-weight: 900;
  color:#111827;
}
.history-subtitle{
  margin:8px 0 0;
  font-size: 13px;
  color:#6b7280;
}

.history-categories{
  margin-bottom: 4px;
  overflow: hidden;
}
.history-category-tabs{
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  -webkit-overflow-scrolling: touch;
}
.history-category-tab{
  flex: 0 0 auto;
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.history-category-tab:hover{
  border-color: #d1d5db;
  background: #f9fafb;
}
.history-category-tab.is-active{
  background: #111827;
  border-color: #111827;
  color: #fff;
}

.history-toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 14px;
  padding: 12px 0 16px;
}
.history-left{
  display:flex;
  align-items:center;
  gap: 14px;
  flex:1;
}
.history-tabs{
  display:flex;
  gap: 8px;
  align-items:center;
}
.history-tab{
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background:#fff;
  color:#111827;
  font-size: 12px;
  font-weight: 700;
  cursor:pointer;
  font-family: inherit;
}
.history-tab.is-active{
  background:#111827;
  border-color:#111827;
  color:#fff;
}

.history-search{
  position:relative;
  display:flex;
  align-items:center;
  gap: 8px;
  flex: 0 1 360px;
  height: 34px;
  border: 1px solid #e5e7eb;
  background:#fff;
  border-radius: 999px;
  padding: 0 12px 0 36px;
}
.history-search-icon{
  position:absolute;
  left: 12px;
  color:#9ca3af;
}
.history-search-input{
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 12px;
  color:#111827;
  font-family: inherit;
}
.history-search-input::placeholder{ color:#9ca3af; }

.history-right{
  display:flex;
  align-items:center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.history-batch-bar{
  display:flex;
  align-items:center;
  gap: 8px;
  flex-wrap: wrap;
}
.history-batch-btn{
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.history-batch-btn:hover{
  background: #f9fafb;
  border-color: #d1d5db;
}
.history-batch-btn.is-danger{
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}
.history-batch-btn.is-danger:hover:not(:disabled){
  background: #fee2e2;
}
.history-batch-btn.is-danger:disabled{
  opacity: 0.45;
  cursor: not-allowed;
}
.history-batch-btn.is-ghost{
  background: transparent;
  border-color: transparent;
  color: #6b7280;
}
.history-batch-count{
  font-size: 13px;
  font-weight: 600;
  color: #111827;
}
.history-card.is-select-mode{
  position: relative;
  cursor: pointer;
}
.history-card.is-selected{
  outline: 2px solid #111827;
  outline-offset: 2px;
}
.history-card-check{
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid #fff;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.history-card.is-selected .history-card-check{
  background: #111827;
  border-color: #111827;
  color: #fff;
}

.history-date{
  display:flex;
  align-items:center;
  gap: 10px;
}
.history-date-label{
  font-size: 12px;
  color:#9ca3af;
}
.history-date-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background:#fff;
  font-size: 12px;
  font-weight: 700;
  color:#111827;
  cursor:pointer;
  font-family: inherit;
}
.history-date-btn:hover{ background:#f9fafb; }

.history-content{ padding-top: 8px; position: relative; }
.history-list{ display:flex; flex-direction:column; gap: 22px; }
.history-group-title{
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 800;
  color: #111827;
}
.history-grid{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.history-loading{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  padding: 28px 0;
  color: #6b7280;
  font-size: 13px;
}
.history-loading[hidden]{
  display: none !important;
}
.history-load-sentinel{
  width: 100%;
  height: 1px;
  pointer-events: none;
}
.history-loading-spinner{
  width: 18px;
  height: 18px;
  border: 2px solid #e5e7eb;
  border-top-color: #111827;
  border-radius: 50%;
  animation: history-spin 0.8s linear infinite;
}
@keyframes history-spin{ to { transform: rotate(360deg); } }
.history-end{
  padding: 20px 0 8px;
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
}
.history-date-wrap{ position: relative; }
.history-date-btn.has-range{
  border-color: #111827;
  background: #f9fafb;
}
.history-date-picker{
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 300px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
  z-index: 30;
}
.history-date-picker-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 8px;
}
.history-date-month{
  font-size: 13px;
  font-weight: 800;
  color: #111827;
}
.history-date-nav{
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: #f3f4f6;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.history-date-picker-week,
.history-date-picker-grid{
  display:grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.history-date-picker-week span{
  text-align:center;
  font-size: 11px;
  color: #9ca3af;
  padding: 4px 0;
}
.history-date-day{
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.history-date-day.is-today{ font-weight: 800; }
.history-date-day.is-selected,
.history-date-day.is-range-start,
.history-date-day.is-range-end{
  background: #111827;
  color: #fff;
}
.history-date-day.is-in-range{ background: #f3f4f6; }
.history-date-hint{
  margin: 10px 0 0;
  font-size: 11px;
  color: #6b7280;
}
.history-date-picker-foot{
  display:flex;
  justify-content:flex-end;
  gap: 8px;
  margin-top: 12px;
}
.history-date-foot-btn{
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.history-date-foot-btn.is-primary{
  background: #111827;
  border-color: #111827;
  color: #fff;
}
@media (max-width: 1100px){
  .history-grid{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px){
  .history-toolbar{ flex-direction:column; align-items:stretch; }
  .history-left{ flex-direction:column; align-items:stretch; }
  .history-search{ flex: 1; max-width: none; }
  .history-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px){
  .history-grid{ grid-template-columns: 1fr; }
}

.history-card{
  display:block;
  width:100%;
  text-align:left;
  border: 1px solid #eef2f7;
  border-radius: 14px;
  background:#fff;
  overflow:hidden;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  cursor:pointer;
  transition: box-shadow .2s, transform .2s;
  font-family: inherit;
  padding: 0;
}
.history-card:hover{
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.1);
  transform: translateY(-1px);
}
.history-thumb{
  width: 100%;
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, #f3f4f6, #ffffff);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}
.history-thumb img{
  width:100%;
  height:100%;
  object-fit: cover;
  display:block;
}
.history-thumb.is-video{
  color: #6b7280;
  background: linear-gradient(135deg, #111827, #374151);
}
.history-thumb.is-video svg{ color: #fff; opacity: .9; }
.history-thumb.is-empty{
  font-size: 12px;
  color: #9ca3af;
  padding: 12px;
  text-align: center;
}
.history-status{
  display:inline-flex;
  margin-top: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #f3f4f6;
  color: #6b7280;
}
.history-status.is-completed{ background:#ecfdf5; color:#047857; }
.history-status.is-failed{ background:#fef2f2; color:#b91c1c; }
.history-status.is-processing,
.history-status.is-pending{ background:#eff6ff; color:#1d4ed8; }
.history-meta-tool{ font-weight: 700; color: #374151; }
.history-meta-dot{ color: #d1d5db; }
.history-empty-icon{
  display:flex;
  justify-content:center;
  margin-bottom: 10px;
  color: #d1d5db;
}
.history-empty-sub{
  margin: 6px 0 0;
  font-size: 12px;
  color: #9ca3af;
}
.history-meta{
  padding: 10px 12px 12px;
}
.history-meta-title{
  font-size: 13px;
  font-weight: 800;
  color:#111827;
  margin: 0 0 4px;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-meta-sub{
  font-size: 12px;
  color:#6b7280;
  display:flex;
  align-items:center;
  gap: 8px;
}
.history-meta-sub svg{ color:#9ca3af; }

.history-empty{
  padding: 64px 0 20px;
  text-align:center;
  color:#9ca3af;
}
.history-empty-text{
  font-size: 12px;
}

.history-toast{
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  z-index: 10001;
  box-shadow: 0 10px 24px rgba(0,0,0,0.25);
}

.history-preview{
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.history-preview[hidden]{ display: none !important; }
.history-preview-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
}
.history-preview-dialog{
  position: relative;
  width: min(1100px, 100%);
  max-height: min(88vh, 900px);
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28);
  display: flex;
  flex-direction: column;
}
.history-preview-close{
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.06);
  color: #111827;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.history-preview-close:hover{ background: rgba(17, 24, 39, 0.12); }
.history-preview-body{
  display: grid;
  grid-template-columns: 1fr 280px;
  min-height: 420px;
  max-height: min(88vh, 900px);
}
.history-preview-media-wrap{
  position: relative;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 360px;
}
.history-preview-media{
  width: 100%;
  height: 100%;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.history-preview-media img,
.history-preview-media video{
  max-width: 100%;
  max-height: min(72vh, 760px);
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.history-preview-empty{
  color: #94a3b8;
  font-size: 14px;
  text-align: center;
  padding: 24px;
  line-height: 1.7;
}
.history-preview-nav{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #111827;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  z-index: 1;
}
.history-preview-nav.is-prev{
  left: 16px;
  transform: translateY(-50%) rotate(180deg);
}
.history-preview-nav.is-next{ right: 16px; }
.history-preview-side{
  padding: 24px 20px 20px;
  border-left: 1px solid #eef2f7;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}
.history-preview-title{
  margin: 28px 0 0;
  font-size: 16px;
  font-weight: 800;
  color: #111827;
  line-height: 1.4;
  word-break: break-word;
}
.history-preview-meta{
  margin: 0;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.6;
}
.history-preview-thumbs{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.history-preview-thumb{
  width: 56px;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
  background: #f3f4f6;
}
.history-preview-thumb.is-active{ border-color: #111827; }
.history-preview-thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.history-preview-actions{
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
}
.history-preview-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #111827;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.history-preview-btn:hover{ background: #f9fafb; }
.history-preview-btn.is-danger{
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}
.history-preview-btn.is-danger:hover{ background: #fee2e2; }
.history-preview-btn:disabled{
  opacity: 0.45;
  cursor: not-allowed;
}
@media (max-width: 900px){
  .history-preview-body{
    grid-template-columns: 1fr;
    max-height: 92vh;
    overflow: auto;
  }
  .history-preview-side{
    border-left: 0;
    border-top: 1px solid #eef2f7;
  }
  .history-preview-media-wrap{ min-height: 280px; }
  .history-preview-media{ min-height: 280px; }
}
