.video-app {
  max-width: 1120px;
}

.video-app .title {
  background: none;
  color: var(--danger);
  -webkit-text-fill-color: var(--danger);
}

.video-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
  gap: 20px;
  flex: 1;
}

.video-workspace {
  min-width: 0;
}

.page-nav {
  text-align: left;
  margin-bottom: 8px;
}

.page-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

.page-nav a:hover {
  color: var(--accent);
}

.field {
  margin-bottom: 18px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.text-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9375rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row .text-input {
  flex: 1;
}

.btn-icon {
  padding: 10px 12px;
  flex-shrink: 0;
}

.field-hint {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.prompt-field {
  position: relative;
}

.reference-mention-menu {
  position: absolute;
  z-index: 20;
  right: 0;
  left: 0;
  top: calc(100% + 4px);
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.reference-mention-menu[hidden] {
  display: none;
}

.mention-option {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.mention-option:hover,
.mention-option.is-active {
  background: rgba(59, 130, 246, 0.14);
}

.mention-option img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
}

.mention-option-name {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.8125rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-option-token {
  color: #93c5fd;
  font-size: 0.75rem;
  font-weight: 600;
}

.keyframe-input + .keyframe-input {
  margin-top: 14px;
}

.range-limits {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.btn-generate {
  width: 100%;
  margin-top: 8px;
  padding: 14px 20px;
  font-size: 1rem;
}

.btn-generate:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.result-card {
  border-color: rgba(59, 130, 246, 0.25);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.result-title {
  font-size: 1rem;
  font-weight: 600;
}

.status-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.status-badge.queued,
.status-badge.in_progress {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.status-badge.completed {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.status-badge.failed {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.progress-wrap {
  margin-bottom: 16px;
}

.progress-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #6366f1);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress-text {
  margin-top: 10px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.video-preview video {
  width: 100%;
  border-radius: var(--radius-sm);
  background: #000;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

.video-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.meta-list {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  font-size: 0.8125rem;
}

.meta-list dt {
  color: var(--text-muted);
}

.meta-list dd {
  color: var(--text);
  word-break: break-all;
}

.error-box {
  padding: 12px 14px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.875rem;
  line-height: 1.6;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.ref-image-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ref-upload-btn {
  width: 100%;
  padding: 14px 16px;
  border-style: dashed;
}

.ref-image-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
}

.ref-image-list[hidden] {
  display: none;
}

.ref-image-item {
  position: relative;
  min-width: 0;
  padding: 7px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.ref-image-thumb {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  object-fit: cover;
  border-radius: 5px;
}

.ref-image-token {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 5px 4px;
  overflow: hidden;
  color: #93c5fd;
  background: transparent;
  border: 0;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.ref-image-token:hover {
  color: #bfdbfe;
}

.ref-image-remove {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 26px;
  height: 26px;
  padding: 0;
  color: #fff;
  background: rgba(10, 14, 23, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  font-size: 1.125rem;
  line-height: 22px;
  cursor: pointer;
}

.setting-row-wrap {
  flex-wrap: wrap;
}

.segmented-wrap {
  flex-wrap: wrap;
}

/* Generation history */
.history-panel {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-height: calc(100dvh - 40px);
  padding: 18px;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.history-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.history-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.history-header p {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.history-clear,
.history-delete {
  border: 0;
  color: var(--text-muted);
  font-family: var(--font);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.history-clear {
  padding: 5px 8px;
  background: transparent;
  font-size: 0.75rem;
}

.history-clear:hover,
.history-delete:hover {
  color: var(--danger);
}

.history-empty {
  padding: 44px 8px;
  text-align: center;
}

.history-empty p {
  color: var(--text);
  font-size: 0.875rem;
}

.history-empty span {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 149, 168, 0.35) transparent;
}

.history-item {
  flex: none;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.history-item-header,
.history-meta,
.history-actions {
  display: flex;
  align-items: center;
}

.history-item-header {
  justify-content: space-between;
  gap: 8px;
}

.history-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  font-size: 0.6875rem;
  font-weight: 600;
}

.history-status.status-completed {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.history-status.status-failed {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.history-delete {
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border-radius: 6px;
  font-size: 1.125rem;
  line-height: 1;
}

.history-delete:hover {
  background: rgba(239, 68, 68, 0.1);
}

.history-prompt {
  margin-top: 10px;
  color: var(--text);
  font-size: 0.8125rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.history-meta {
  flex-wrap: wrap;
  gap: 2px 8px;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.6875rem;
}

.history-video {
  display: block;
  width: 100%;
  margin-top: 10px;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #000;
  border-radius: 6px;
}

.history-actions {
  gap: 8px;
  margin-top: 10px;
}

.history-link {
  color: #93c5fd;
  font-size: 0.75rem;
  text-decoration: none;
}

.history-link:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .video-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .history-panel {
    position: static;
    max-height: 480px;
  }
}

@media (max-width: 480px) {
  .segment {
    padding: 8px 8px;
    font-size: 0.6875rem;
  }

  .video-app {
    padding-right: 14px;
    padding-left: 14px;
  }

  .history-panel {
    max-height: 400px;
    padding: 16px;
  }
}
