.workspace:has(.view[data-view="records"].is-active) .view-stage {
  --records-top-shift: min(20px, max(0px, calc(var(--stage-padding) - 4px)));
  padding-top: calc(var(--stage-padding) - var(--records-top-shift));
  background: #fff;
}

.view[data-view="records"].is-active {
  height: 100%;
  min-height: 0;
  background: #fff;
  overflow: hidden;
}

.records-workspace {
  height: calc(100vh - 72px - (var(--stage-padding) * 2) + var(--records-top-shift));
  min-height: 620px;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 16px;
  color: #344054;
}

.records-page-head {
  min-height: 40px;
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.records-page-title {
  margin: 0;
  color: #111827;
  font-size: 24px;
  font-weight: 700;
  line-height: 32px;
}

.record-filter-toolbar {
  min-width: 0;
  display: grid;
  grid-template-columns: 280px repeat(5, 148px) 128px auto;
  align-items: center;
  justify-content: start;
  gap: 12px;
  min-height: 72px;
  padding: 14px 16px;
  border: 1px solid #e8edf5;
  border-radius: var(--rect-radius, 8px);
  background: #ffffff;
  box-shadow: 0 4px 16px rgba(33, 43, 67, 0.04);
}

.record-search-control {
  position: relative;
  min-width: 0;
}

.record-search-control > svg,
.record-search-control > i {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 17px;
  height: 17px;
  color: #344054;
  pointer-events: none;
  transform: translateY(-50%);
}

.record-input,
.record-select,
.record-date-input {
  width: 100%;
  height: 40px;
  min-width: 0;
  border: 1px solid #e8edf5;
  border-radius: var(--rect-radius, 8px);
  padding: 0 36px 0 12px;
  color: #344054;
  background-color: #ffffff;
  font-size: 14px;
  font-weight: 400;
  line-height: 22px;
  outline: 0;
}

.record-input::placeholder { color: #98a2b3; }

.record-input:focus,
.record-select:focus,
.record-date-input:focus {
  border-color: #00afe9;
  box-shadow: 0 0 0 3px rgba(0, 175, 233, 0.1);
}

.record-select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #344054 50%), linear-gradient(135deg, #344054 50%, transparent 50%);
  background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

.record-query-button {
  height: 44px;
  min-width: 128px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--rect-radius, 8px);
  padding: 0 20px;
  color: #ffffff;
  background: linear-gradient(90deg, #00afe9 0%, #5cc8f4 100%);
  box-shadow: 0 4px 12px rgba(0, 175, 233, 0.18);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
}

.record-clear-button {
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  padding: 0 4px;
  color: #667085;
  background: transparent;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  white-space: nowrap;
}

.record-clear-button:hover,
.record-clear-button:focus-visible { color: #00afe9; }
.record-query-button:disabled,
.record-clear-button:disabled { cursor: wait; opacity: 0.62; }

.records-shell {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  overflow: hidden;
}

.records-main-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 36px minmax(0, 1fr);
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

.records-main-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 0 2px;
}

.records-summary {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  color: #111827;
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
}

.records-summary-count { color: #00afe9; font-weight: 600; }
.records-view-controls { display: inline-flex; align-items: center; gap: 8px; }

.record-sort-select {
  width: 116px;
  height: 32px;
  padding: 0 28px 0 8px;
  border: 1px solid #b8c4d2;
  border-radius: var(--rect-radius, 8px);
  color: #667085;
  background-color: #ffffff;
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  font-size: 12px;
}

.records-view-toggle {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid #e8edf5;
  border-radius: var(--rect-radius, 8px);
  background: #ffffff;
}

.records-view-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  color: #667085;
  background: #ffffff;
}

.records-view-button + .records-view-button { border-left: 1px solid #e8edf5; }
.records-view-button svg, .records-view-button i { width: 15px; height: 15px; }
.records-view-button.is-active { color: #ffffff; background: #00afe9; }

.records-gallery-viewport {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 2px 10px 16px 2px;
  scrollbar-color: #aeb7c4 #eef2f6;
  scrollbar-width: thin;
}

.records-gallery-viewport::-webkit-scrollbar { width: 8px; }
.records-gallery-viewport::-webkit-scrollbar-track { border-radius: 999px; background: #eef2f6; }
.records-gallery-viewport::-webkit-scrollbar-thumb {
  min-height: 120px;
  border: 1px solid #eef2f6;
  border-radius: 999px;
  background: #aeb7c4;
  background-clip: padding-box;
}

.records-gallery {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-content: start;
  gap: 12px;
}

.records-gallery.is-list-view { grid-template-columns: 1fr; }

.record-card {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid #e8edf5;
  border-radius: var(--rect-radius, 8px);
  padding: 0;
  color: #344054;
  background: #ffffff;
  text-align: left;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.record-card:hover { border-color: rgba(0, 175, 233, 0.42); transform: translateY(-1px); }
.record-card.is-active { border-color: #00afe9; box-shadow: 0 0 0 1px rgba(0, 175, 233, 0.12); }
.record-thumb { position: relative; aspect-ratio: 1.26 / 1; overflow: hidden; background: #f7fbff; }
.record-thumb > img, .record-thumb > .record-preview-scene { width: 100%; height: 100%; object-fit: cover; }

.record-expiry-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  color: #cd140f;
  background: #fff2f0;
  font-size: 12px;
  font-weight: 400;
}

.record-card-body {
  min-width: 0;
  display: grid;
  grid-template-rows: repeat(2, minmax(0, auto));
  gap: 4px;
  padding: 10px;
}
.record-card-primary-row,
.record-card-secondary-row { min-width: 0; display: grid; align-items: center; gap: 8px; }
.record-card-primary-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
.record-card-secondary-row { grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px; }
.record-card-title { margin: 0; overflow: hidden; color: #111827; font-size: 14px; font-weight: 500; line-height: 22px; text-overflow: ellipsis; white-space: nowrap; }
.record-card-time, .record-card-meta-line { margin: 0; overflow: hidden; color: #667085; font-size: 12px; font-weight: 400; line-height: 18px; text-overflow: ellipsis; white-space: nowrap; }
.record-card-time { text-align: right; }
.record-card-ratio { text-align: right; }
.record-card-footer { display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; }
.record-card-footer .record-status { padding: 0 4px; }

.record-status {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 8px;
  color: #03b144;
  background: #edfff5;
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
}

.record-status.failed { color: #cd140f; background: #fff2f0; }
.record-status.running { color: #667085; background: #f2f4f7; }
.record-card-size { color: #667085; font-size: 12px; line-height: 18px; }
.records-gallery.is-list-view .record-card { grid-template-columns: 168px minmax(0, 1fr); grid-template-rows: 112px; }
.records-gallery.is-list-view .record-thumb { aspect-ratio: auto; }

.records-detail-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  align-content: start;
  gap: 12px;
  padding: 16px;
  border: 1px solid #e8edf5;
  border-radius: var(--rect-radius, 8px);
  background: #ffffff;
  box-shadow: 0 4px 16px rgba(33, 43, 67, 0.04);
  overflow: hidden;
}

.record-detail-preview { position: relative; height: 286px; overflow: hidden; border: 1px solid #e8edf5; border-radius: var(--rect-radius, 8px); background: #f7fbff; }
.record-detail-preview > img { width: 100%; height: 100%; object-fit: contain; object-position: center; }
.record-detail-preview > .record-preview-scene { width: 100%; height: 100%; object-fit: cover; }
.record-detail-empty { width: 100%; height: 100%; display: grid; place-items: center; color: #98a2b3; font-size: 14px; font-weight: 400; }
.record-output-selector {
  display: flex;
  gap: 8px;
  min-height: 54px;
  overflow-x: auto;
  padding: 2px;
}
.record-output-selector[hidden] { display: none; }
.record-output-option {
  flex: 0 0 50px;
  width: 50px;
  height: 50px;
  padding: 2px;
  overflow: hidden;
  border: 1px solid #d8e1ec;
  border-radius: var(--rect-radius, 8px);
  background: #ffffff;
}
.record-output-option.is-active { border-color: #00afe9; box-shadow: 0 0 0 1px #00afe9; }
.record-output-option img { width: 100%; height: 100%; object-fit: cover; border-radius: 5px; }
.record-detail-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 38px; gap: 8px; }

.record-detail-action {
  min-width: 0;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #00afe9;
  border-radius: var(--rect-radius, 8px);
  color: #00afe9;
  background: #ffffff;
  font-size: 14px;
  font-weight: 400;
  line-height: 22px;
  white-space: nowrap;
}

.record-detail-action.is-primary { color: #ffffff; background: linear-gradient(90deg, #00afe9 0%, #5cc8f4 100%); box-shadow: 0 4px 12px rgba(0, 175, 233, 0.18); }
.record-detail-action.is-danger { width: 38px; padding: 0; border: 0; color: #cd140f; background: transparent; }
.record-detail-action.is-danger:hover { background: #fff2f0; }
.record-detail-action.is-danger:focus-visible { outline: 2px solid rgba(205, 20, 15, 0.22); outline-offset: 2px; }
.record-detail-action svg, .record-detail-action i { width: 16px; height: 16px; }
.record-detail-action.is-danger svg, .record-detail-action.is-danger i { width: 18px; height: 18px; }
.record-detail-action:disabled, .record-copy-button:disabled { cursor: not-allowed; opacity: 0.48; }
.record-detail-scroll { min-height: 0; display: grid; align-content: start; gap: 10px; overflow-x: hidden; overflow-y: auto; padding-right: 2px; }
.record-prompt-section { display: grid; gap: 8px; }
.record-prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #667085; font-size: 14px; font-weight: 500; line-height: 22px; }
.record-copy-button { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: var(--rect-radius, 8px); color: #667085; background: transparent; }
.record-copy-button:hover { color: #00afe9; background: #e7f8fe; }
.record-copy-button img, .record-copy-button svg, .record-copy-button i { width: 15px; height: 15px; }
.record-prompt-box { height: 185px; overflow-x: hidden; overflow-y: auto; padding: 12px; border: 1px solid #e8edf5; border-radius: var(--rect-radius, 8px); background: #ffffff; scrollbar-color: #aeb7c4 #eef2f6; scrollbar-width: thin; }
.record-prompt-box::-webkit-scrollbar { width: 8px; }
.record-prompt-box::-webkit-scrollbar-track { border-radius: 999px; background: #eef2f6; }
.record-prompt-box::-webkit-scrollbar-thumb { border: 1px solid #eef2f6; border-radius: 999px; background: #aeb7c4; background-clip: padding-box; }
.record-prompt-text { margin: 0; color: #667085; font-size: 12px; font-weight: 400; line-height: 20px; white-space: pre-wrap; overflow-wrap: anywhere; }
.record-info-table { display: grid; overflow: hidden; margin-top: 20px; border: 1px solid #e8edf5; border-radius: var(--rect-radius, 8px); background: #ffffff; }
.record-info-row { min-height: 34px; display: grid; grid-template-columns: 94px minmax(0, 1fr); align-items: center; gap: 8px; padding: 0 10px; border-bottom: 1px solid #e8edf5; color: #667085; font-size: 12px; font-weight: 400; line-height: 18px; }
.record-info-row > :is(span, strong) { font-size: 12px; font-weight: 400; line-height: 18px; }
.record-info-row:last-child { border-bottom: 0; }
.record-info-row span:first-child { color: #98a2b3; }
.record-info-row strong { overflow: hidden; color: #667085; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }

.records-empty { grid-column: 1 / -1; padding: 48px 16px; border: 1px dashed rgba(0, 175, 233, 0.32); border-radius: var(--rect-radius, 8px); color: #667085; background: #ffffff; text-align: center; }

@media (max-width: 1599px) {
  .records-workspace {
    height: calc(100vh - 64px - (var(--stage-padding) * 2) + var(--records-top-shift));
  }
  .record-filter-toolbar { grid-template-columns: 220px repeat(5, 128px) 112px auto; gap: 8px; padding: 12px; }
  .records-gallery { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .record-detail-preview { height: 230px; }
}

@media (max-width: 1399px) {
  .record-filter-toolbar { grid-template-columns: 200px repeat(5, 112px) 112px auto; }
  .record-query-button, .record-clear-button { grid-column: auto; }
  .records-shell { grid-template-columns: minmax(0, 1fr) 300px; }
  .records-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .view[data-view="records"].is-active { height: auto; overflow: visible; }
  .records-workspace { height: auto; min-height: 0; }
  .record-filter-toolbar, .records-shell { grid-template-columns: 1fr; }
  .records-gallery-viewport, .records-detail-scroll { overflow: visible; }
  .records-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
