.video-tool-page {
  min-height: 100%;
  color: var(--label, #1c1c1e);
  background: var(--bg, #f2f2f7);
}

.video-tool-page.active {
  display: block;
  overflow: auto;
}

.video-tool-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 56px;
}

.video-tool-head {
  width: 100%;
  min-height: 0;
  margin-bottom: 30px;
  padding: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  position: static;
  background: none;
  border: 0;
  box-shadow: none;
}

.video-tool-head > div { max-width: 790px; }

.video-tool-kicker {
  display: block;
  margin-bottom: 9px;
  color: var(--accent, #7c5cff);
  font: 700 11px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .16em;
}

.video-tool-head h1 {
  margin: 0;
  color: var(--label, #1c1c1e);
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.08;
  letter-spacing: -.045em;
}

.video-tool-head p {
  max-width: 680px;
  margin: 13px 0 0;
  color: var(--label-2, #666);
  font-size: 15px;
  line-height: 1.75;
}

.video-tool-spec {
  min-width: 142px;
  display: grid;
  justify-items: end;
  padding: 0 0 5px 22px;
  border-left: 1px solid var(--separator, rgba(60, 60, 67, .2));
}

.video-tool-spec b {
  color: var(--label, #1c1c1e);
  font: 800 34px/.95 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: -.08em;
}

.video-tool-spec small {
  margin-top: 8px;
  color: var(--label-3, #8e8e93);
  font: 700 9px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .12em;
  white-space: nowrap;
}

.video-tool-inputs {
  display: grid;
  grid-template-columns: minmax(300px, .92fr) minmax(360px, 1.08fr);
  gap: 18px;
  align-items: stretch;
}

.video-input-pane {
  min-width: 0;
  padding: 18px;
  background: var(--surface, #fff);
  border: 1px solid var(--separator, rgba(60, 60, 67, .16));
  border-radius: 14px;
}

.video-pane-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.video-pane-label > span {
  color: var(--accent, #7c5cff);
  font: 700 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.video-pane-label strong {
  color: var(--label, #1c1c1e);
  font-size: 15px;
  letter-spacing: -.01em;
}

.video-dropzone {
  position: relative;
  min-height: 390px;
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: pointer;
  background: color-mix(in srgb, var(--surface, #fff) 90%, var(--accent, #7c5cff) 10%);
  border: 1px dashed color-mix(in srgb, var(--label-2, #777) 40%, transparent);
  border-radius: 13px;
  transition: border-color .16s ease, background .16s ease;
}

.video-dropzone:hover,
.video-dropzone.is-dragging {
  border-color: var(--accent, #7c5cff);
  background: color-mix(in srgb, var(--surface, #fff) 84%, var(--accent, #7c5cff) 16%);
}

.video-dropzone:focus-within {
  outline: 2px solid var(--accent, #7c5cff);
  outline-offset: 3px;
}

#video-image-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.video-image-empty {
  display: grid;
  place-items: center;
  gap: 7px;
  padding: 28px;
  color: var(--label-2, #666);
  text-align: center;
}

.video-image-empty b {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin-bottom: 5px;
  color: var(--accent, #7c5cff);
  font-size: 26px;
  font-weight: 400;
  border: 1px solid color-mix(in srgb, var(--accent, #7c5cff) 48%, transparent);
  border-radius: 50%;
}

.video-image-empty strong {
  color: var(--label, #1c1c1e);
  font-size: 15px;
}

.video-image-empty small,
.video-file-meta,
.video-prompt-meta,
.video-cost-note {
  color: var(--label-3, #8e8e93);
  font-size: 12px;
}

#video-preview {
  width: 100%;
  height: 390px;
  display: block;
  object-fit: contain;
  background: #0a0a0b;
}

.video-file-meta {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 2px 0;
}

#video-file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#video-clear-image {
  flex: 0 0 auto;
  padding: 4px 0;
  color: var(--accent, #7c5cff);
  background: none;
  border: 0;
  cursor: pointer;
}

.video-prompt-pane {
  display: flex;
  flex-direction: column;
}

.video-engine-switch {
  margin-bottom: 11px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 4px;
  background: color-mix(in srgb, var(--surface, #fff) 91%, var(--label, #111) 9%);
  border: 1px solid var(--separator, rgba(60, 60, 67, .16));
  border-radius: 11px;
}

.video-engine-switch button {
  min-width: 0;
  min-height: 50px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 7px 10px;
  color: var(--label-2, #666);
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  font: inherit;
  cursor: pointer;
}

.video-engine-switch button strong { font-size: 12px; }
.video-engine-switch button small { color: var(--label-3, #8e8e93); font-size: 10px; }

.video-engine-switch button.is-active {
  color: var(--label, #1c1c1e);
  background: var(--surface, #fff);
  border-color: color-mix(in srgb, var(--accent, #7c5cff) 52%, var(--separator, #aaa));
}

.video-engine-switch button.is-active strong { color: var(--accent, #7c5cff); }
.video-engine-switch button:disabled { opacity: .48; cursor: wait; }
.video-engine-switch button:focus-visible { outline: 2px solid var(--accent, #7c5cff); outline-offset: 2px; }

.video-lora-picker {
  min-width: 0;
  margin: 0 0 11px;
  padding: 11px 12px 12px;
  border: 1px solid var(--separator, rgba(60, 60, 67, .16));
  border-radius: 11px;
}

.video-lora-picker legend {
  max-width: 100%;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 5px;
  color: var(--label, #1c1c1e);
}

.video-lora-picker legend strong { font-size: 12px; }
.video-lora-picker legend span { color: var(--label-3, #8e8e93); font-size: 10px; font-weight: 500; }

.video-lora-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.video-lora-options label {
  min-width: 0;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  color: var(--label-2, #666);
  background: color-mix(in srgb, var(--surface, #fff) 94%, var(--accent, #7c5cff) 6%);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.video-lora-options label:has(input:checked) {
  color: var(--label, #1c1c1e);
  border-color: color-mix(in srgb, var(--accent, #7c5cff) 58%, var(--separator, #aaa));
  background: color-mix(in srgb, var(--surface, #fff) 87%, var(--accent, #7c5cff) 13%);
}

.video-lora-options input {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--accent, #7c5cff);
}

.video-lora-options span { min-width: 0; display: grid; gap: 2px; }
.video-lora-options b { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.video-lora-options small { overflow: hidden; color: var(--label-3, #8e8e93); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.video-lora-options input:focus-visible { outline: 2px solid var(--accent, #7c5cff); outline-offset: 3px; }
.video-lora-picker.is-disabled { opacity: .46; }
.video-lora-picker.is-disabled label { cursor: not-allowed; }

#video-prompt {
  width: 100%;
  min-height: 190px;
  flex: 1 1 auto;
  resize: vertical;
  padding: 16px;
  color: var(--label, #1c1c1e);
  background: color-mix(in srgb, var(--surface, #fff) 94%, var(--label, #111) 6%);
  border: 1px solid var(--separator, rgba(60, 60, 67, .16));
  border-radius: 13px;
  font: inherit;
  font-size: 15px;
  line-height: 1.72;
}

#video-prompt:focus {
  outline: 2px solid color-mix(in srgb, var(--accent, #7c5cff) 70%, transparent);
  outline-offset: 2px;
  border-color: transparent;
}

.video-prompt-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 2px 0;
  line-height: 1.45;
}

#video-prompt-count {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.video-generate-button {
  min-height: 52px;
  margin-top: 20px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  background: var(--accent, #7c5cff);
  border: 0;
  border-radius: 9px;
  font: inherit;
  font-size: 15px;
  font-weight: 720;
  cursor: pointer;
}

.video-generate-button:hover { filter: brightness(1.06); }
.video-generate-button:active { transform: translateY(1px); }
.video-generate-button:disabled { opacity: .46; cursor: wait; }

.video-cost-note {
  margin: 9px 2px 0;
  line-height: 1.5;
}

.video-section-head {
  min-height: 28px;
  margin: 30px 2px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.video-section-head > div {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.video-section-head > div > span {
  color: var(--accent, #7c5cff);
  font: 700 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.video-section-head h2 {
  margin: 0;
  color: var(--label, #1c1c1e);
  font-size: 15px;
  letter-spacing: -.01em;
}

.video-section-head > small,
.video-history-intro {
  color: var(--label-3, #8e8e93);
  font-size: 12px;
}

.video-output {
  min-height: 170px;
  margin-top: 0;
  padding: 18px;
  display: grid;
  place-items: center;
  background: var(--surface, #fff);
  border: 1px solid var(--separator, rgba(60, 60, 67, .16));
  border-radius: 14px;
}

.video-output-empty {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--label-2, #666);
}

.video-image-empty[hidden],
.video-progress[hidden],
.video-error[hidden],
#video-result-figure[hidden],
#video-clear-image[hidden],
#video-preview[hidden] {
  display: none !important;
}

.video-output-empty > span {
  color: var(--accent, #7c5cff);
  font: 740 28px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.video-output-empty div {
  display: grid;
  gap: 4px;
}

.video-output-empty strong { color: var(--label, #1c1c1e); font-size: 14px; }
.video-output-empty small { color: var(--label-3, #8e8e93); font-size: 12px; }

.video-progress {
  width: min(560px, 100%);
  display: grid;
  gap: 9px;
  text-align: center;
}

.video-progress-track {
  height: 4px;
  overflow: hidden;
  background: color-mix(in srgb, var(--label-3, #999) 24%, transparent);
  border-radius: 99px;
}

#video-progress-bar {
  width: 2%;
  height: 100%;
  display: block;
  background: var(--accent, #7c5cff);
  transition: width .3s ease;
}

.video-progress strong { color: var(--label, #1c1c1e); font-size: 14px; }
.video-progress small { color: var(--label-3, #8e8e93); font-variant-numeric: tabular-nums; }

.video-error {
  display: grid;
  gap: 5px;
  color: #c93f45;
  text-align: center;
}

.video-error span { max-width: 620px; color: var(--label-2, #666); font-size: 13px; }

#video-result-figure {
  width: min(620px, 100%);
  margin: 0;
}

#video-result {
  width: 100%;
  max-height: 68vh;
  display: block;
  background: #050506;
  border-radius: 13px;
}

#video-result-figure figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px 0;
  color: var(--label-3, #8e8e93);
  font-size: 12px;
}

#video-download {
  color: var(--accent, #7c5cff);
  font-weight: 650;
  text-decoration: none;
}

.video-history-section { margin-top: 34px; }

.video-history-head {
  margin: 0 2px;
  padding-top: 22px;
  border-top: 1px solid var(--separator, rgba(60, 60, 67, .16));
}

#video-history-count {
  min-width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  color: var(--accent, #7c5cff);
  background: color-mix(in srgb, var(--accent, #7c5cff) 12%, transparent);
  border-radius: 99px;
  font: 700 10px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

#video-history-refresh {
  min-height: 34px;
  padding: 0 12px;
  color: var(--label-2, #666);
  background: transparent;
  border: 1px solid var(--separator, rgba(60, 60, 67, .2));
  border-radius: 7px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

#video-history-refresh:hover { color: var(--label, #1c1c1e); border-color: var(--accent, #7c5cff); }
#video-history-refresh:disabled { opacity: .45; cursor: wait; }
#video-history-refresh:focus-visible,
.video-history-cover:focus-visible,
.video-history-actions button:focus-visible {
  outline: 2px solid var(--accent, #7c5cff);
  outline-offset: 2px;
}

.video-history-intro {
  margin: 7px 2px 16px;
  line-height: 1.55;
}

.video-history-state {
  min-height: 96px;
  display: grid;
  place-items: center;
  color: var(--label-3, #8e8e93);
  border: 1px dashed var(--separator, rgba(60, 60, 67, .2));
  border-radius: 12px;
  font-size: 13px;
}

.video-history-state[hidden] { display: none !important; }
.video-history-state.is-error { color: #c93f45; }

.video-history-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.video-history-card {
  min-width: 0;
  overflow: hidden;
  background: var(--surface, #fff);
  border: 1px solid var(--separator, rgba(60, 60, 67, .16));
  border-radius: 14px;
  transition: border-color .16s ease, transform .16s ease;
}

.video-history-card:hover {
  border-color: color-mix(in srgb, var(--accent, #7c5cff) 58%, var(--separator, #aaa));
  transform: translateY(-2px);
}

.video-history-cover {
  width: 100%;
  aspect-ratio: 16 / 10;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 0;
  color: #fff;
  background: #09090a;
  border: 0;
  border-bottom: 1px solid var(--separator, rgba(60, 60, 67, .16));
  cursor: pointer;
}

.video-history-cover img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.video-history-play {
  width: 42px;
  height: 42px;
  position: absolute;
  display: grid;
  place-items: center;
  padding-left: 2px;
  color: #fff;
  background: rgba(10, 10, 12, .74);
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 50%;
  font-size: 13px;
  backdrop-filter: blur(8px);
  transition: transform .16s ease, background .16s ease;
}

.video-history-cover:hover .video-history-play {
  background: var(--accent, #7c5cff);
  transform: scale(1.06);
}

.video-history-body {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  padding: 13px 14px 14px;
}

.video-history-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--label-3, #8e8e93);
  font: 650 10px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.video-history-body p {
  min-height: 3.9em;
  margin: 12px 0 16px;
  display: -webkit-box;
  overflow: hidden;
  color: var(--label-2, #666);
  font-size: 13px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.video-history-actions {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.video-history-actions button {
  min-height: 36px;
  padding: 0 10px;
  color: var(--label, #1c1c1e);
  background: color-mix(in srgb, var(--surface, #fff) 91%, var(--accent, #7c5cff) 9%);
  border: 1px solid var(--separator, rgba(60, 60, 67, .16));
  border-radius: 7px;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.video-history-actions button:hover { border-color: var(--accent, #7c5cff); }
.video-history-actions button:disabled { opacity: .38; cursor: not-allowed; }

:where([data-theme="story-warm"], [data-theme="story-dark"]) .tab[data-tab="video"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3.5' y='5' width='13.5' height='14' rx='2' fill='none' stroke='black' stroke-width='1.8'/%3E%3Cpath d='m17 9 3.5-2v10L17 15V9Z' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'/%3E%3Cpath d='m8.5 9 4 3-4 3V9Z' fill='black'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3.5' y='5' width='13.5' height='14' rx='2' fill='none' stroke='black' stroke-width='1.8'/%3E%3Cpath d='m17 9 3.5-2v10L17 15V9Z' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'/%3E%3Cpath d='m8.5 9 4 3-4 3V9Z' fill='black'/%3E%3C/svg%3E");
}

:where([data-theme="story-warm"], [data-theme="story-dark"]) .tab[data-tab="video"]::after { content: "视频"; }

:where([data-theme="story-warm"], [data-theme="story-dark"]) #tab-video.active {
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  background: var(--story-canvas);
}

:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-tool-page {
  color: var(--story-ink);
  background: var(--story-canvas);
}

:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-input-pane,
:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-output,
:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-history-card {
  background: var(--story-panel);
  border-color: var(--story-line);
}

:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-tool-head h1,
:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-tool-spec b,
:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-section-head h2,
:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-pane-label strong,
:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-image-empty strong,
:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-output-empty strong,
:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-progress strong {
  color: var(--story-ink);
}

:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-tool-head p,
:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-section-head > small,
:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-history-intro,
:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-history-body p,
:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-image-empty,
:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-output-empty,
:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-error span {
  color: var(--story-muted);
}

:where([data-theme="story-warm"], [data-theme="story-dark"]) #video-prompt {
  color: var(--story-ink);
  background: color-mix(in srgb, var(--story-panel) 88%, var(--story-ink) 12%);
  border-color: var(--story-line);
}

:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-engine-switch {
  background: color-mix(in srgb, var(--story-panel) 84%, var(--story-ink) 16%);
  border-color: var(--story-line);
}

:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-engine-switch button.is-active {
  color: var(--story-ink);
  background: var(--story-panel);
}

:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-lora-picker {
  border-color: var(--story-line);
}

:where([data-theme="story-warm"], [data-theme="story-dark"]) .video-lora-options label {
  background: color-mix(in srgb, var(--story-panel) 92%, var(--story-accent, #7c5cff) 8%);
}

@media (max-width: 760px) {
  :where([data-theme="story-warm"], [data-theme="story-dark"]) .tabs {
    padding-right: 20%;
  }

  :where([data-theme="story-warm"], [data-theme="story-dark"]) .tab {
    flex-basis: 25%;
  }

  :where([data-theme="story-warm"], [data-theme="story-dark"]) #settings-btn {
    width: 20vw;
  }

  .video-tool-shell {
    width: calc(100% - 22px);
    padding: 24px 0 34px;
  }

  .video-tool-head { margin-bottom: 20px; }
  .video-tool-head { align-items: flex-start; }
  .video-tool-spec { min-width: 118px; }
  .video-tool-head h1 { font-size: 30px; }
  .video-tool-head p { font-size: 13px; }
  .video-tool-inputs { grid-template-columns: minmax(0, 1fr); }
  .video-input-pane { padding: 14px; border-radius: 14px; }
  .video-dropzone { min-height: 300px; }
  #video-preview { height: 300px; }
  #video-prompt { min-height: 210px; }
  .video-prompt-meta { align-items: flex-start; font-size: 11px; }
  .video-generate-button { min-height: 50px; }
  .video-output { min-height: 150px; border-radius: 14px; }
  .video-history-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 540px) {
  .video-tool-head { display: block; }
  .video-tool-spec {
    min-width: 0;
    margin-top: 18px;
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 0 0;
    border-top: 1px solid var(--separator, rgba(60, 60, 67, .2));
    border-left: 0;
  }
  .video-tool-spec b { font-size: 24px; }
  .video-lora-options { grid-template-columns: minmax(0, 1fr); }
  .video-section-head { align-items: flex-end; }
  .video-section-head > small { display: none; }
  .video-history-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 360px) {
  .video-tool-head h1 { font-size: 27px; }
  .video-tool-inputs { gap: 12px; }
  .video-dropzone, #video-preview { min-height: 250px; height: 250px; }
  .video-output-empty { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  #video-progress-bar,
  .video-dropzone,
  .video-generate-button {
    transition: none !important;
  }
  .video-history-card,
  .video-history-play {
    transition: none !important;
  }
}
